Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. FIle

FIle

Scheduled Pinned Locked Moved C#
tutorialdata-structuresquestion
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    papa80
    wrote on last edited by
    #1

    Hi How i can get some information from file which is separeted by semicore. For example. name;age;sex; i need to put all this into array how to do it?

    when i want to read something good just seat and type it

    L E S P 4 Replies Last reply
    0
    • P papa80

      Hi How i can get some information from file which is separeted by semicore. For example. name;age;sex; i need to put all this into array how to do it?

      when i want to read something good just seat and type it

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      string text = File.ReadAllText();
      string[] array = text .Split(';');

      can't get easier than this. regards

      1 Reply Last reply
      0
      • P papa80

        Hi How i can get some information from file which is separeted by semicore. For example. name;age;sex; i need to put all this into array how to do it?

        when i want to read something good just seat and type it

        S Offline
        S Offline
        saqib82
        wrote on last edited by
        #3

        read all the data from the file and store it in a string. then use the string.split() method of c# to split the array. this will return you array having all the records in it without semicore. the syntax is string selectedNode; // to store data from file char[] splitter = { ';' }; // splitter to be used string[] machineNode; // array which will contain the data after splitting the //string machineNode = selectedNode.Split(); now u can use machineNode as any array to retrieve data. regards

        sAqIb

        1 Reply Last reply
        0
        • P papa80

          Hi How i can get some information from file which is separeted by semicore. For example. name;age;sex; i need to put all this into array how to do it?

          when i want to read something good just seat and type it

          E Offline
          E Offline
          ejuanpp
          wrote on last edited by
          #4

          Hope this helps Regards private void _parse(string sourceFile) { string[] tokens; // Check if source file exists if (File.Exists(sourceFile) == false) throw new Exception("Source file does not exist"); TextReader TR = File.OpenText(sourceFile); // Parse file for (string currentLine = TR.ReadLine(); currentLine != null; currentLine = TR.ReadLine()) { tokens = currentLine.Split(";".ToCharArray()); } TR.Close(); }

          1 Reply Last reply
          0
          • P papa80

            Hi How i can get some information from file which is separeted by semicore. For example. name;age;sex; i need to put all this into array how to do it?

            when i want to read something good just seat and type it

            P Offline
            P Offline
            papa80
            wrote on last edited by
            #5

            Thank's too all of you

            when i want to read something good just seat and type it

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups