.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Post New Resource Bookmark and Share   

Create,Delete and Move Directory in a C#.net

Posted By:Narayanan       Posted Date: September 26, 2011    Points: 40    Category:    URL: http://www.dotnetspark.com  

Here , I give a method for create/delete/move a directory in C#.net
 

   public static void CreateDir(string Dir)
        {
            if (!System.IO.Directory.Exists(Dir))
            {
                System.IO.Directory.CreateDirectory(Dir);
            }
            else
            {
                String Path = "Folder Path : " + "  " +  Dir + " " + "is already exists" ;
                System.Windows.Forms.MessageBox.Show(Path);
            }
       }
        public static void DeleteDir(string Dir)
        {
            if (System.IO.Directory.Exists(Dir))
            {
                System.IO.Directory.Delete(Dir);
            }
            else
            {
                String Path = "Please check in" + Dir;
                System.Windows.Forms.MessageBox.Show(Path);
            }
        }
        public static void MoveDir(string OrigPath, string Despath)
        {
            if (!System.IO.Directory.Exists(OrigPath))
            {
                System.IO.Directory.Move(OrigPath, Despath);
            }
            else
            {
                String Path = "Folder does not there";
                System.Windows.Forms.MessageBox.Show(Path);
            }
        }

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend