Results 1 to 5 of 5

Thread: Listview to File.....

  1. #1

    Thread Starter
    Addicted Member theonetrueace's Avatar
    Join Date
    Jan 2002
    Location
    South Alabama
    Posts
    196

    Listview to File.....

    is there a quick and simple way of saving the items in a listview to file?....i would also want to load them back into a listview so readable formatting is not of concern...

    AcE

  2. #2
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Reading, UK
    Posts
    870
    when u say items do u mean rows of data?

    if yes then you could save them as a text file, a new line for each row, and with a comma seperating each value, or in a database.

    Let me know if you need some code.
    www.vb-tech.com
    .Net Freelance Development
    http://weblog.vb-tech.com/nick
    My blog

  3. #3

    Thread Starter
    Addicted Member theonetrueace's Avatar
    Join Date
    Jan 2002
    Location
    South Alabama
    Posts
    196
    yes yes code would be wut im fishing for here....lol....

    AcE

  4. #4
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    I got some C# code here, it saves the listbox contents to a textfile.
    Code:
    private void SaveList()
    {
        string sTemp;
        string sTemp1;
    
        // Get the name the list is supposed to be saved as.
        sTemp = "C:\Myfile.txt";
    
        // Loop through and save all items in list.
        if(lb.Items.Count > 0)
        {
            try
            {
                    // Create a StreamWriter object to write to the file.
    	StreamWriter writer = new StreamWriter(sTemp.ToString(),false);
    
    	// Write the information to the file one line at a time.
    	for(int i = 0; i < lb.Items.Count; i++)
    	{
    	     sTemp1 = lb.Items[i].ToString();
    	    writer.WriteLine(sTemp1);
    	}
    					
    	// Close the StreamWriter object.
    	writer.Close();
           }
           catch(System.Exception except)
          {
               except.Message.ToString());
           }
    }

  5. #5

    Thread Starter
    Addicted Member theonetrueace's Avatar
    Join Date
    Jan 2002
    Location
    South Alabama
    Posts
    196
    i think i can convert this.....will post with result....thx for code...

    AcE

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width