Solved

c# File System method - FolderExists()

Posted on 2008-06-26
3
809 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

688 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