|
-
Mar 28th, 2003, 02:21 AM
#1
Thread Starter
Addicted Member
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
-
Mar 28th, 2003, 06:32 AM
#2
Fanatic Member
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.
-
Mar 28th, 2003, 07:03 PM
#3
Thread Starter
Addicted Member
yes yes code would be wut im fishing for here....lol....
AcE
-
Mar 28th, 2003, 10:36 PM
#4
PowerPoster
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());
}
}
-
Mar 29th, 2003, 03:39 AM
#5
Thread Starter
Addicted Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|