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. How I can Read this File in C#

How I can Read this File in C#

Scheduled Pinned Locked Moved C#
csharp
4 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.
  • M Offline
    M Offline
    mm310
    wrote on last edited by
    #1

    I Need Read this File (STR) Subtitle File And put all data from File in ListView like this http://www.cpestudents.net/upload/up/sub.gif[^] File http://www.cpestudents.net/upload/up/sub2.gif[^]

    N L 2 Replies Last reply
    0
    • M mm310

      I Need Read this File (STR) Subtitle File And put all data from File in ListView like this http://www.cpestudents.net/upload/up/sub.gif[^] File http://www.cpestudents.net/upload/up/sub2.gif[^]

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      Read the textbook again or audit the class

      1 Reply Last reply
      0
      • M mm310

        I Need Read this File (STR) Subtitle File And put all data from File in ListView like this http://www.cpestudents.net/upload/up/sub.gif[^] File http://www.cpestudents.net/upload/up/sub2.gif[^]

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

        Try this one:

        StreamReader s = new StreamReader(@"f:\mytext.txt");

        ArrayList a = new ArrayList();
        while (s.Peek() >= 0)
        {
        string alltext = "";
        string text = "";
        while ((text = s.ReadLine()) != "" && text != null)
        {
        alltext += ("|" + text);
        }
        a.Add(alltext);
        }

        s.Close();

        foreach (string text in a)
        {
        string[] splitString = text.Split('|');

        string tempstring = "";
        for (int i = 3; i < splitString.Length; i++)
        {
             tempstring += splitString\[i\];
        }
        

        ListViewItem lvi = new ListViewItem(new string[] { splitString[1], splitString[2].Substring(0, 12), splitString[2].Substring(17, 12), tempstring });
        this.listView1.Items.Add(lvi);
        }

        D 1 Reply Last reply
        0
        • L Lost User

          Try this one:

          StreamReader s = new StreamReader(@"f:\mytext.txt");

          ArrayList a = new ArrayList();
          while (s.Peek() >= 0)
          {
          string alltext = "";
          string text = "";
          while ((text = s.ReadLine()) != "" && text != null)
          {
          alltext += ("|" + text);
          }
          a.Add(alltext);
          }

          s.Close();

          foreach (string text in a)
          {
          string[] splitString = text.Split('|');

          string tempstring = "";
          for (int i = 3; i < splitString.Length; i++)
          {
               tempstring += splitString\[i\];
          }
          

          ListViewItem lvi = new ListViewItem(new string[] { splitString[1], splitString[2].Substring(0, 12), splitString[2].Substring(17, 12), tempstring });
          this.listView1.Items.Add(lvi);
          }

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          Wow, nothing like doin' his classwork for him. Now he'll definately fail the class! Dave Kreskowiak Microsoft MVP - Visual Basic

          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