Click here to Skip to main content
15,890,185 members
Please Sign up or sign in to vote.
1.25/5 (5 votes)
See more:
I want to create folder in current date ,like 26-9-2014 this first ,then again i want the folder in current date in same location.

I want

c:\\download\26-9-2014

26-9-2014_1

26-9-2014_2

like that want to create.
Posted
Comments
Sergey Alexandrovich Kryukov 26-Sep-14 3:19am    
What's wrong with reading original MSDN documentation?
—SA

 
Share this answer
 
try this

C#
string path = @"E:\test";
         DirectoryInfo di = new DirectoryInfo(path);
         if (di.Exists)
         {
             string exp = DateTime.Now.ToString("dd-MM-yyyy") + "*";
             string[] dirs = Directory.GetDirectories(path, exp + "*");
             int count = dirs.Length;
             Directory.CreateDirectory(path + "\\" + exp.TrimEnd('*') + "_" + (count + 1));
         }


good luck ;-)
 
Share this answer
 
C#
Directory.CreateDirectory(DateTime.Now.ToString("dd-MM-yyyy"));
 
Share this answer
 
Here In this Path you mentioned test (Test is folder name which is there in 'D' drive) in this folder you will find 26-9-2014_1,26-9-2014_2 26-9-2014_3 folders
string path = @"D:\test";
DirectoryInfo di = new DirectoryInfo(path);
if (di.Exists)
{
   string exp = DateTime.Now.ToString("dd-MM-yyyy") + "*";
   string[] dirs = Directory.GetDirectories(path, exp + "*");
   int count = dirs.Length;
   Directory.CreateDirectory(path + "\\" + exp.TrimEnd('*') + "_" + (count + 1));
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900