Monday, 3 September 2012

0 How to create folder using c#

 Friends this is an example to how to create a folder or directory in C# or asp.net using C#.

Open New Project

// Add Namespace

 using System.IO;




Paste the below code on the event where you want.

for example  if you want to create a directory on a button click then you have to take a button on your project.

Then double click on the button then you will find the CS file of that page is open. now wright below code

// Creating folder on Button click

  private void button1_Click(object sender, EventArgs e)
      
 {
     //Here folderpath is a variable which is use to define the path of the folder where you want to create  
          
            string folderpath = @"C:\myfolder";
   
            if (!Directory.Exists(folderpath))

            {
                Directory.CreateDirectory(folderpath);
            }

                messagebox.show("Folder is created.....");


        }

0 comments:

Post a Comment

 

Coding Authority Copyright © 2011 - |- Template created by O Pregador - |- Powered by Blogger Templates