dcsimg
Results 1 to 4 of 4

Thread: [RESOLVED] Is User's Temp folder ALWAYS writable

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2004
    Posts
    141

    Resolved [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?

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    40,349

    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.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    May 2004
    Posts
    141

    Re: Is User's Temp folder ALWAYS writable

    Quote Originally Posted by si_the_geek View Post
    You should treat it as always writeable, .............
    Thanks si_

    I suspected as much but wanted confirmation from somebody with more knowledge/experience.

  4. #4
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,216

    Re: Is User's Temp folder ALWAYS writable

    Quote Originally Posted by Axcontrols View Post
    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
  •  



Featured


Click Here to Expand Forum to Full Width