Solved

c# File System method - FolderExists()

Posted on 2008-06-26
3
799 Views
Last Modified: 2008-06-26
Greetings:

I'm hoping to get code and supporting namespace that will execute the following routine:

FolderExists()

For example:

using ??

void CheckFolder()
{
...                      // necessary variables like 'string FolderPath'
FolderExists()       // correct call
return;
}

Thanks
0
Comment
Question by:John500
3 Comments
 
LVL 16

Accepted Solution

by:
burakiewicz earned 500 total points
ID: 21876479
using System.IO;

Directory.Exists(strPath);
0
 
LVL 6

Expert Comment

by:Bruce_1975
ID: 21876490
The function you are searchin for is included in the System.IO.Directory - class:
System.IO.Directory.Exists("MyFolder")

Regards,
Bruce
0
 
LVL 18

Expert Comment

by:jcoehoorn
ID: 21876902
I see you're asking a lot of file and directory questions all at once, meaning you're probably going to need a bunch of information about a file or directory at the same point in your program.

With that in mind, there are two main ways to get all of this information in .Net:  
1) System.IO.File/System.IO.Directory
2) System.IO.FileInfo/System.IO.DirectoryInfo

As people show you how to do things, as you get various answers from people you should probably favor the FileInfo/DirectoryInfo method to avoid needing to make repeated calls out to the file system.

For example, in this case you could also do it like this, and if you need other information about the directory at the same time it's probably the better choice:
System.IO.DirectoryInfo di = new System.IO.DirectoryInfo("MyFolder");

di.Exists();

Open in new window

0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now