Click here to Skip to main content
15,912,897 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I am new to C#,I am creating the .html file in C#, but i don't have any idea how to save in root directory(i.e Folder created by DateTimeStamp),Please suggest me how to save file in given diractory ,my code is
filename = String.Concat(Headline,".html");

     DateTimeStamp = DateTime.Now.Day.ToString() + DateTime.Now.Month.ToString() +    DateTime.Now.Year.ToString();

     if (!Directory.Exists(DateTimeStamp))
     {
         Directory.CreateDirectory(Server.MapPath(DateTimeStamp));
     }
Posted
Updated 3-Jan-14 0:40am
v4
Comments
Where it is saving currently?
SVT02 3-Jan-14 6:38am    
Actually it does not saving anywhere
Orcun Iyigun 3-Jan-14 6:43am    
Are you sure the path is correct?

1 solution

Refer - Directory.CreateDirectory Method (String)[^]
Quote:
Creates all directories and subdirectories in the specified path.

So, when you write the following code...
C#
Directory.CreateDirectory(Server.MapPath(DateTimeStamp));

It creates a Directory Name as DateTimeStamp.

Simply it means that it will create a folder name as the value contained in DateTimeStamp inside Website Root folder. It can't create the file for you.
 
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