Click here to Skip to main content
15,921,276 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I wann to create runtime directory in root folder. By this code
string strDate = DateTime.Now.ToString("d-M-yyh:mm:ss.ffftt").ToString();
Directory.CreateDirectory(Server.MapPath("~/Images/Work/") + ddl_category.SelectedItem.Text).CreateSubdirectory(strDate);

But i am getting some error. so please me, How to Create directory with its sub folder at runtime.
What is that error?

Hi if you want to create directory from server be sure your user have a access permissions on this directory you can check it by right click on root directory and check the security tab or you do it with IIS or your target web server facilities and after that you can see follow of links how to create directory at run time with code :[^][^][^][^]

Best Regards
Share this answer
The problem is you are trying to create a directory that contains ':' characters. Here:
string strDate = DateTime.Now.ToString("d-M-yyh:mm:ss.ffftt").ToString();

That is not possible.
You should rethink the naming scheme for one that is compatible with NTFS filesystem.

Please see NTFS Naming Conventions[^]

(Moreover, why do you call ToString() method twice? Don't you trust the first call to return a string value?)
Share this answer

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