.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 Sub Folder in Directory using C#.net

Posted By:Narayanan       Posted Date: February 17, 2012    Points: 40    Category:    URL: http://www.dotnetspark.com  

Create Sub Folder in Directory using C#.net
 

 public static string fname;
        public static string Path;
        public static string fldname;
        public static bool mess;

      public static bool createFolder(string sPath, string foldername)
        {
                #region Check folder Name
                bool chkTool = Directory.Exists(sPath);
                if (chkTool)
                {
                    fname = @"\" + foldername + "\\";
                    fname = sPath + fname;
                    Directory.CreateDirectory(fname);
                    mess = true;
                }
                else if (!chkTool)
                {
                    if (!Directory.Exists(sPath))
                    {
                        Directory.CreateDirectory(sPath);
                    }
                    fname = @"\" + foldername + "\\";
                    fname = sPath + fname;
                    Directory.CreateDirectory(fname);
                    mess = true;
                }
                #endregion Check folder Name
                return mess;

        }

 private void btn_Folder_Click(object sender, EventArgs e)
        {
            Path = @"E:\Test";
            fldname = "Test1";
            bool chk = createFolder(Path, fldname);
            if (chk)
            {
                MessageBox.Show("Folder Created");
            }
            else
            {
                MessageBox.Show("Folder is not Create");
            }

        }

     

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