Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


c# File System method - FolderExists()

Posted on 2008-06-26
Medium Priority
Last Modified: 2008-06-26

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


For example:

using ??

void CheckFolder()
...                      // necessary variables like 'string FolderPath'
FolderExists()       // correct call

Question by:John500
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
LVL 16

Accepted Solution

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


Expert Comment

ID: 21876490
The function you are searchin for is included in the System.IO.Directory - class:

LVL 18

Expert Comment

by:Joel Coehoorn
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");

Open in new window


Featured Post

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

636 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