| | |
Loop through all files in folder
Please support our C# advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
Thread Solved
![]() |
You can use foreach cycle. E.g. like this:
c# Syntax (Toggle Plain Text)
foreach(string fileName f in Directory.GetFiles("SomeDirectory")) { ... }
So what if you can see the darkest side of me?
No one would ever change this animal I have become
Help me believe it's not the real me
Somebody help me tame this animal
No one would ever change this animal I have become
Help me believe it's not the real me
Somebody help me tame this animal
•
•
Join Date: Jan 2009
Posts: 68
Reputation:
Solved Threads: 0
Thanks, but it gives me the error that the Directory doesn't exists in the current context.
How can I declare it?
How can I declare it?
•
•
•
•
You can use foreach cycle. E.g. like this:
c# Syntax (Toggle Plain Text)
foreach(string fileName f in Directory.GetFiles("SomeDirectory")) { ... }
•
•
Join Date: Aug 2008
Posts: 1,735
Reputation:
Solved Threads: 186
You dont.. Its a predefined class in .net - have a check in your helpfile, its clever and tells you what references (if necessary) and what "using" statements you would need
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Direcrory class placed in System.IO. So you sould add import to it:
c# Syntax (Toggle Plain Text)
using System.IO;
Last edited by Antenka; Jan 4th, 2009 at 4:12 pm.
So what if you can see the darkest side of me?
No one would ever change this animal I have become
Help me believe it's not the real me
Somebody help me tame this animal
No one would ever change this animal I have become
Help me believe it's not the real me
Somebody help me tame this animal
•
•
Join Date: Jan 2009
Posts: 68
Reputation:
Solved Threads: 0
Thanks, got it.
•
•
•
•
Direcrory class placed in System.IO. So you sould add import to it:
c# Syntax (Toggle Plain Text)
using System.IO;
•
•
Join Date: Jan 2009
Posts: 68
Reputation:
Solved Threads: 0
How can I display a message showing the fileNames retrieved from the given directory.
1.
foreach(string fileName f in Directory.GetFiles("SomeDirectory"))
2.
{
3.
...
4.
}
1.
foreach(string fileName f in Directory.GetFiles("SomeDirectory"))
2.
{
3.
...
4.
}
•
•
•
•
Direcrory class placed in System.IO. So you sould add import to it:
c# Syntax (Toggle Plain Text)
using System.IO;
•
•
Join Date: Aug 2008
Posts: 1,735
Reputation:
Solved Threads: 186
Have you looked at what you get in the foreach loop?
OK while that code wont work specifically it has a big raving clue in it...
What do you think the clue is?
OK while that code wont work specifically it has a big raving clue in it...
What do you think the clue is?
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
When you call GetFiles method, it return to you an array of strings (filenames). To show them in the message, you should organize them in way, that you like into a string. After that you can see here a bit about showing messages: MessageBox Class
So what if you can see the darkest side of me?
No one would ever change this animal I have become
Help me believe it's not the real me
Somebody help me tame this animal
No one would ever change this animal I have become
Help me believe it's not the real me
Somebody help me tame this animal
•
•
Join Date: Jan 2009
Posts: 68
Reputation:
Solved Threads: 0
Thanks, I'm done for now. Wasn't using right syntax for message box. Thanks for all your help.
c ya tomorrow!!!
Regards,
Ali
c ya tomorrow!!!
Regards,
Ali
•
•
•
•
When you call GetFiles method, it return to you an array of strings (filenames). To show them in the message, you should organize them in way, that you like into a string. After that you can see here a bit about showing messages: MessageBox Class
![]() |
Similar Threads
- How to access folder in vba to impot files? (Visual Basic 4 / 5 / 6)
- need python user need help!folder! (Python)
- Deleting Files (PHP)
- How to delete a folder? (C++)
- Array (C++)
- scanning files in a spec folder (JavaScript / DHTML / AJAX)
- Extracting folder information with c++ (C++)
- Application Data Folder... (Viruses, Spyware and other Nasties)
Other Threads in the C# Forum
- Previous Thread: TagPrefix and Assembly error
- Next Thread: spss to c#
| Thread Tools | Search this Thread |
.net access algorithm angle array asp.net bitmap box broadcast c# capturing check checkbox client combobox control conversion csharp database databasesearch datagrid datagridview dataset datetime dbconnection degrees delegate design development disappear draganddrop drawing encryption enum eventhandlers excel file firefox form format forms function gdi+ grantorrevokepermissionthroughc#.net image input install interface java libraries list loop marshalbyrefobject math monodevelop mouseclick movingimage msword mysql operator path pause photoshop php picturebox pixelinversion platform polynomial post programming properties radians regex remoting richtextbox server sleep socket sql statistics string study system.servicemodel table tcpclientchannel text textbox thread time timer update usb usercontrol validation virtualization visualbasic visualstudio wpf wpfc# xml






