Click here to Skip to main content
15,914,795 members
Home / Discussions / C#
   

C#

 
AnswerRe: how to get copied files from windows to my application ?? Pin
SeMartens3-Feb-09 2:08
SeMartens3-Feb-09 2:08 
GeneralRe: how to get copied files from windows to my application ?? Pin
ahmedhassan963-Feb-09 2:16
ahmedhassan963-Feb-09 2:16 
GeneralRe: how to get copied files from windows to my application ?? Pin
SeMartens3-Feb-09 2:21
SeMartens3-Feb-09 2:21 
GeneralRe: how to get copied files from windows to my application ?? Pin
Dave Kreskowiak3-Feb-09 4:06
mveDave Kreskowiak3-Feb-09 4:06 
AnswerRe: how to get copied files from windows to my application ?? Pin
Dave Kreskowiak3-Feb-09 4:06
mveDave Kreskowiak3-Feb-09 4:06 
QuestionSave/Export Listbox Content to a file !? Pin
vantoora3-Feb-09 1:42
vantoora3-Feb-09 1:42 
AnswerRe: Save/Export Listbox Content to a file !? Pin
tech6033-Feb-09 3:37
tech6033-Feb-09 3:37 
GeneralRe: Save/Export Listbox Content to a file !? Pin
vantoora10-Feb-09 2:37
vantoora10-Feb-09 2:37 
Thanks for your reply but it does not what I expect to have. Maybe my question is not quiet clear so I'll explain first what I want to have.
So I have one listbox that I populate with a result of a calculation. Let's say the listbox contains 100 items.
What I need is to save those list items into a file (maybe I want them later even if I already closed the program for another process).
What you showed me is just the way how to write into a file but not how to retrieve all value of the list and save them into a file.
This is what I want.

But, fortunately, I know now how to save the listbox contents :
1. I count the number of items : listbox1.Items.Count;
2. recursively set each Items selected : listbox1.SetSelected(i, true);
and StreamWriter each selected Items directly.

for example :
int number = listbox1.Items.Count;
StreamWriter sw = new StreamWriter(@"C:\list.csv");
for (int i = 0; i < number; i++)
{
listbox1.SetSelected(i, true);
sw.WriteLine(listbox1.SelectedItems[i].ToString());
}
sw.Close();

Hope this will help someone else. (of course you can personalize it like adding savefiledialog...)

Cheers, Big Grin | :-D
AnswerRe: Save/Export Listbox Content to a file !? Pin
tech6033-Feb-09 3:39
tech6033-Feb-09 3:39 
QuestionDisconnect a FTP connection Pin
benjamin yap3-Feb-09 1:40
benjamin yap3-Feb-09 1:40 
AnswerRe: Disconnect a FTP connection Pin
EliottA3-Feb-09 2:28
EliottA3-Feb-09 2:28 
GeneralRe: Disconnect a FTP connection Pin
benjamin yap3-Feb-09 2:45
benjamin yap3-Feb-09 2:45 
GeneralRe: Disconnect a FTP connection Pin
EliottA3-Feb-09 2:46
EliottA3-Feb-09 2:46 
GeneralRe: Disconnect a FTP connection Pin
benjamin yap3-Feb-09 3:09
benjamin yap3-Feb-09 3:09 
GeneralRe: Disconnect a FTP connection Pin
EliottA3-Feb-09 3:16
EliottA3-Feb-09 3:16 
QuestionSmart Card Pin
Mohd Atiq3-Feb-09 1:29
Mohd Atiq3-Feb-09 1:29 
AnswerRe: Smart Card Pin
SeMartens3-Feb-09 1:36
SeMartens3-Feb-09 1:36 
GeneralThe use of 'var' Pin
Nathan Gloyn3-Feb-09 1:15
Nathan Gloyn3-Feb-09 1:15 
GeneralRe: The use of 'var' Pin
J4amieC3-Feb-09 1:24
J4amieC3-Feb-09 1:24 
GeneralRe: The use of 'var' Pin
SeMartens3-Feb-09 1:42
SeMartens3-Feb-09 1:42 
GeneralRe: The use of 'var' Pin
Nathan Gloyn3-Feb-09 8:57
Nathan Gloyn3-Feb-09 8:57 
GeneralRe: The use of 'var' Pin
Eddy Vluggen3-Feb-09 1:40
professionalEddy Vluggen3-Feb-09 1:40 
GeneralRe: The use of 'var' Pin
Rob Philpott3-Feb-09 2:03
Rob Philpott3-Feb-09 2:03 
GeneralRe: The use of 'var' Pin
Gideon Engelberth3-Feb-09 3:11
Gideon Engelberth3-Feb-09 3:11 
GeneralRe: The use of 'var' Pin
PIEBALDconsult3-Feb-09 4:26
mvePIEBALDconsult3-Feb-09 4:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.