Jane T
Jane T

Reputation: 81

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

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

Upvotes: 3

Views: 141

Answers (3)

this. __curious_geek
this. __curious_geek

Reputation: 43207

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");

Upvotes: 0

Dan Diplo
Dan Diplo

Reputation: 25339

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

Upvotes: 0

Mark Redman
Mark Redman

Reputation: 24515

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.

Upvotes: 2

Related Questions