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.
Creating file in asp.net and saving it on server?
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Raaj KumarRank #7,836 · 233 reputationPosted Feb 22, 2010, 6:13 PM EST
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
Rujuta133 reputationPosted Feb 22, 2010, 6:30 PM EST
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