i have this task checking the folder if exist and if not create a folder. This is simple.
First i need to create a form with 1 textbox, button and a label in my page. I named the textbox as txtFolderName, button btnCheckandCreate and the label as lblMessage so now,  I need to put the event in my button on click..  on the onclick eventon the button  i need to put the code.
protected void btnCheckandCreate _Click(object sender, EventArgs e)
   {
       lblMessage.Text = "";
       if (!System.IO.Directory.Exists(@"c:\" + txtFolderName.Text.ToUpper()  + ""))
       {
           System.IO.Directory.CreateDirectory(@"c:\" + txtFolderName.Text.ToUpper() + "");
       }
       else {
           lblMessage.Text = txtFolderName.Text + " is available";
       }
   }
Thats it. its so simple. at first i need to set the lblmessage to set to empty then check the inputed if is the folder exist and if not it will create a folder on it else put an message that the foldername is existing. hope this help.
Features
Thursday, August 28, 2008
Subscribe to:
Post Comments (Atom)
 
No comments:
Post a Comment