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.....");
}
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