Hi
I have made some code that creates a file for later use. The file just needs to me stored at a temporily place on the server. What do I write in my code if I want to save the file in a certain folder on the server? The file shoul dnot be save among the aspx files and the other web site content but in a folder that not should be accesiably from other than the website.
Loading
RujutaPosted Feb 22, 2010, 11:30 PM
File.WriteAllText("File Path", "File's Content");
Though I'm still confused how did generate a file without providing a path to save it?
Please mark this post as answer if it helps resolve your problems
Raaj KumarPosted Feb 22, 2010, 11:13 PM
Try this code,
and in code behind,
string fileName = System.IO.Path.GetFileName(MyFile.PostedFile.FileName);
string saveLocation = Server.MapPath("TempFiles" + "\\" + fileName);
MyFile.PostedFile.SaveAs(saveLocation);
Regards,
Raaj