IT Community - Software Programming, Web Development and Technical Support

How to find whether a folder exists or not using c#?

This is a discussion on How to find whether a folder exists or not using c#? within the C# Programming forums, part of the Software Development category; How to check a particular folder exsist or Not using c#?...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Software Development > C# Programming

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 07-24-2007, 04:21 AM
kingmaker kingmaker is offline
D-Web Genius
 
Join Date: Jun 2007
Posts: 882
kingmaker is on a distinguished road
Send a message via Yahoo to kingmaker
Question How to find whether a folder exists or not using c#?

How to check a particular folder exsist or Not using c#?
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-24-2007, 05:00 AM
oxygen oxygen is offline
D-Web Architect
 
Join Date: Jun 2007
Posts: 633
oxygen is on a distinguished road
Default Re: How to check a particular folder exsist or Not using c#?

How to check a particular folder using c#?

private bool CheckFolder(string targetFolder)

{
bool folderExists = Directory.Exists(targetFolder);
if (!folderExists)
{
do something
}
else if (folderExists = "myfolderName")

{
DeleteFile(@\\myfolderName\);

}
return folderExists;

}
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 08-23-2007, 12:52 AM
S.Vinothkumar S.Vinothkumar is offline
D-Web Genius
 
Join Date: May 2007
Posts: 1,061
S.Vinothkumar is on a distinguished road
Wink Re: How to check a particular folder exsist or Not using c#?

We can check the folder exists or not in .Net 2.0 by using the following single line of code.

Code:
if (!Directory.Exists("C:/vinoth"))
 {
    Directory.CreateDirectory("C:/vinoth");
 }
That's it...
__________________
S.VinothkumaR
Behind me is infinite power,
Before me is Endless Possibility,
Around me is Boundless Opportunity,
Why should I fear!
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Check to see if a cfwindow exists BenR41 ColdFusion Programming 2 06-24-2008 12:17 AM
pagination for a folder? saravanan PHP Programming 0 03-21-2008 04:53 AM
CON Folder in Windows Sabari Server Management 1 12-01-2007 02:40 AM
Can we put the reference dll in to a specific folder? amansundar C# Programming 3 10-28-2007 11:51 PM
Using C# and VB.NET classes together in the App_Code folder Gopisoft VB.NET Programming 0 07-17-2007 09:39 PM


All times are GMT -7. The time now is 05:58 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0