In a ASP.NET program is there a location where I can I write temporary files?

StackOverflow https://stackoverflow.com/questions/2583592

  •  24-09-2019
  •  | 
  •  

Question

In a ASP.NET program is there a location where I can I write temporary files? Assuming a default IIS installation, the program running under anonymous user?

Thank you

No correct solution

OTHER TIPS

You can pretty much save temporary files anywhere on disk as long as you have permissions. You will just need to make sure the files are uniquely named per anonymous user.

Ideally having a dedicated "temporary" folder is a good idea, where these files will be deleted or cleaned up periodically.

You could (and probably should) use System.IO.Path.GetTempPath(). If you want .NET to take care of generating a uniquely named random, temporary file then use the GetTempFileName() method also in System.IO.Path

No there's no such built-in mechanism available for asp.net

What you can do is create the one witihn your application root and use it for temp operations like this.

string tempPath = Server.MapPath("~\\temp");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top