Click here to Skip to main content
15,891,184 members
Home / Discussions / C#
   

C#

 
QuestionCrystal Report Pin
mjawadkhatri26-Jan-10 21:41
mjawadkhatri26-Jan-10 21:41 
Questionget files one by one in the lable Pin
tanweer26-Jan-10 21:31
tanweer26-Jan-10 21:31 
AnswerRe: get files one by one in the lable Pin
sanforjackass26-Jan-10 21:40
sanforjackass26-Jan-10 21:40 
GeneralRe: get files one by one in the lable Pin
tanweer26-Jan-10 21:55
tanweer26-Jan-10 21:55 
GeneralRe: get files one by one in the lable Pin
sanforjackass26-Jan-10 21:59
sanforjackass26-Jan-10 21:59 
GeneralRe: get files one by one in the lable Pin
tanweer26-Jan-10 22:05
tanweer26-Jan-10 22:05 
GeneralRe: get files one by one in the lable Pin
sanforjackass26-Jan-10 22:18
sanforjackass26-Jan-10 22:18 
GeneralRe: get files one by one in the lable Pin
OriginalGriff26-Jan-10 22:10
mveOriginalGriff26-Jan-10 22:10 
tanweer akhtar wrote:
for (int i = 0; i < Directory.GetFiles(textBox1.Text).Length - 1; i++)
{
object[] file=Directory.GetFiles(textBox1.Text+@"\");
label2.Text = file[i].ToString();
}
timer1.Stop();
}


Yes, it will show only the last file in the list. Try replacing:
label2.Text = file[i].ToString();
with
label2.Text += file[i].ToString();
as this means the new name will be appended to the existing text, rather than replacing it.

You will also want to clear the label2.Text before entering the for loop, and add a newline to the end of the name (or they will all run together in one big line).

Other improvements you may want to do:

1) Change the label for a ListBox - it is better designed for showing lists than a label.
2) Consider using foreach rather than your existing for loop:
DirectoryInfo dir = new DirectoryInfo(dirname);
 foreach (FileInfo fi in dir.GetFiles())
     {
     string filename = fi.FullName;
     ...
     }


All those who believe in psycho kinesis, raise my hand.

My Badger | [badger,badger,badger,badger...] 's gonna unleash hell on your ass. Badger | [badger,badger,badger,badger...] tastic!

Questiondatagridview scrolling Pin
prithaa26-Jan-10 20:26
prithaa26-Jan-10 20:26 
QuestionEventHandler for Textbox Pin
Anu_Bala26-Jan-10 20:21
Anu_Bala26-Jan-10 20:21 
QuestionThread issue Pin
Mycroft Holmes26-Jan-10 18:50
professionalMycroft Holmes26-Jan-10 18:50 
AnswerRe: Thread issue Pin
Rob Philpott26-Jan-10 20:52
Rob Philpott26-Jan-10 20:52 
GeneralRe: Thread issue Pin
Mycroft Holmes26-Jan-10 21:04
professionalMycroft Holmes26-Jan-10 21:04 
GeneralRe: Thread issue Pin
David Skelly26-Jan-10 22:18
David Skelly26-Jan-10 22:18 
Questionre:vs C# versus vsC++ Pin
Alan Kurlansky26-Jan-10 17:28
Alan Kurlansky26-Jan-10 17:28 
AnswerRe: re:vs C# versus vsC++ Pin
tolw26-Jan-10 19:56
tolw26-Jan-10 19:56 
GeneralRe: re:vs C# versus vsC++ Pin
Alan Kurlansky27-Jan-10 4:08
Alan Kurlansky27-Jan-10 4:08 
GeneralRe: re:vs C# versus vsC++ Pin
tolw27-Jan-10 6:14
tolw27-Jan-10 6:14 
Questionregex help Pin
uglyeyes26-Jan-10 13:34
uglyeyes26-Jan-10 13:34 
Answerrepost Pin
Luc Pattyn26-Jan-10 13:40
sitebuilderLuc Pattyn26-Jan-10 13:40 
AnswerRe: regex help Pin
vivasaayi26-Jan-10 18:19
vivasaayi26-Jan-10 18:19 
GeneralRe: regex help Pin
uglyeyes26-Jan-10 21:15
uglyeyes26-Jan-10 21:15 
GeneralRe: regex help Pin
#realJSOP27-Jan-10 1:24
mve#realJSOP27-Jan-10 1:24 
GeneralRe: regex help Pin
uglyeyes27-Jan-10 2:26
uglyeyes27-Jan-10 2:26 
GeneralRe: regex help Pin
basantakumar27-Jan-10 3:20
basantakumar27-Jan-10 3:20 

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.