C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » C# Syntax »

Create and Delete Directory in ASP.NET


Posted Date: 04 Nov 2009    Resource Type: Code Snippets    Category: C# Syntax
Author: Lakhan PalMember Level: Diamond    
Rating: 1 out of 5Points: 10



This Code will be used to create a new directory and to delete existing directory.

suppose we want to create a new directory name TestDirectory on c:/drive.

First we will check if the directory with this name already exists then there is no need to create.
namespace that need to be used for this is:
using System.IO;


Code To Create Directory:

string FilePath=@"C:\TestDirectory";
if (!System.IO.Directory.Exists(FilePath))
Directory.CreateDirectory(FilePath);


To Delete Directory first we will check if the directory exists then delete.
Code To Delete Directory:

string FilePath=@"C:\TestDirectory";
if (System.IO.Directory.Exists(FilePath))
Directory.Delete(FilePath,true);


Thanks & Regards
Lakhan Pal Garg



Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
System.IO  .  Directory  .  Delete Directory  .  Create Directory  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Modify the web.config's value at runtime
Previous Resource: Convert an Image to Icon
Return to Discussion Resource Index
Post New Resource
Category: C# Syntax


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use