-
Mar 4th, 2018, 09:15 AM
#1
Thread Starter
Addicted Member
[RESOLVED] Is User's Temp folder ALWAYS writable
I need to save some temp data somewhere.
I plan on using Path.GetTempPath()
Are there any circumstances where the user won't have permission to write to that folder
I was looking at st4ck 0verfl0w and one guy was saying that Path.GetTepPath got him a non-writable folder on some dongle drive - why would such a thing happen? Bad coding? or is there some legitimate reason why a sys admin would want to prevent his user's apps writing to the user's own temp folder?
-
Mar 4th, 2018, 09:53 AM
#2
Re: Is User's Temp folder ALWAYS writable
From the documentation: https://msdn.microsoft.com/en-us/lib...v=vs.110).aspx
Remarks
This method checks for the existence of environment variables in the following order and uses the first path found:
The path specified by the TMP environment variable.
The path specified by the TEMP environment variable.
The path specified by the USERPROFILE environment variable.
The Windows directory.
Environment variables are system settings, which to some degree are changeable by the users... if they decide to stop programs creating temp files, that is presumably an option (and is presumably what happened in your dongle example).
It would be a very unusual situation, and you should almost certainly ignore it - because it would be the users choice to stop their computer from working properly.
You should treat it as always writeable, but as always with disk based operations use appropriate exception handling to deal with any problems.
-
Mar 4th, 2018, 10:20 AM
#3
Thread Starter
Addicted Member
Re: Is User's Temp folder ALWAYS writable
Originally Posted by si_the_geek
You should treat it as always writeable, .............
Thanks si_
I suspected as much but wanted confirmation from somebody with more knowledge/experience.
-
Mar 5th, 2018, 06:41 AM
#4
Re: Is User's Temp folder ALWAYS writable
Originally Posted by Axcontrols
Thanks si_
I suspected as much but wanted confirmation from somebody with more knowledge/experience.
Which folders are writable depends on not only the OS but also the security. %TEMP% folder as said should be treated as writeable. Without writing access to temp, many applications won't run at all
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|