C# – Creating and saving a text file to the server

asp.netc++

In C# ASP.Net, I would like to create and save a text file to a server. This will be happening daily (by a user action, not scheduled).

I would like the location to not be in the application path but in a separate folder (for this question, lets say the folder is off the root).

I am new to this site and if this question is too "open", feel free to let me know.

Thanks for your assistance.

Best Solution

I agree with Dan Herbert. Put the path in web.config and make sure the permissions for the folder are correct.

Also, make sure that path is not on the C drive. That way, if something goes wrong, or if the site is attacked, the c drive won't fill up and crash the server.

Be careful with the permissions; even a simple text file can be dangerous if a hacker can muck with the path somehow. Think about someone overwriting the server's hosts file, for example.