2
C:\Users\username\AppData\Roaming
C:\Users\username\AppData\Local\Temp

I am writing an app for windows and my app will be using these two locations above quite often and to avoid any surprises I want to know for sure if Windows allow these locations to have spaces in their paths like for example:

C:\Users\user Name\AppData\Roaming
C:\Users\user Name\AppData\Local\Temp

I went through a couple of MS docs but couldn't find this specific info.

2
  • 3
    Can they have spaces? Yes; If the username has a space which is why you should create the path using a method where it won’t matter. System variables exist for a reason and %LocalData% (or a programming language equivalent) is very helpful
    – Ramhound
    Aug 1 at 17:59
  • 1
    Spaces have been allowed in folder names for ages. There is no excuse for building software that doesn't support them correctly.
    – gronostaj
    Aug 2 at 20:28
8

They certainly could, and not only because of the user name.

In all Windows 2000/XP systems, those two directories were located at:

C:\Documents and Settings\User\Application Data
C:\Documents and Settings\User\Local Settings\Temp

(I've heard rumors that this naming was chosen deliberately, to force newly written programs to accept long file names in case "C:\Program Files" wasn't enough of a push.)

While those Windows versions are now mostly out-of-support, such paths may still linger in app configurations if the same system was directly upgraded from 2000/XP to Vista/7 and from there to Win8/10. They remain valid paths in modern versions, too, thanks to Windows creating hidden symlinks pointing the old names to new ones.

In general, a well-written program should always assume that any path might contain spaces, commas, apostrophes, and other funny things. They've been allowed in paths ever since "C:\My Documents" in Windows 95 – in 2021 they should be a baseline assumption, not a "surprise"!

0
7

There are no limitation on the user-name/account-name. It may contain spaces, and the documentation doesn't see the need to mention that.

For example see the post Windows 10 - Username with whitespace and PATH, where the user name was "Miha Šušteršič".

3
  • File name documentation which does not see fit to enumerate invalid characters is Very Bad Documentation.
    – RonJohn
    Aug 2 at 17:02
  • 2
    The invalid characters are these that are not allowed in file names.
    – harrymc
    Aug 2 at 19:00
  • That still means "It may contain spaces, and the documentation doesn't see the need to mention that" can be misinterpreted.
    – RonJohn
    Aug 2 at 21:00
3

You can have spaces in the name.

Here is an example on my own machine.

Otherwise folder names should be used exactly as Windows has them (e.g. AppData does not have spaces).

User name with spaces

3
  • I can still make out your surname in the title bar, and you have it on the search bar top-right. Aug 2 at 13:57
  • Title bar still needs a little more obfuscation ;) Aug 2 at 15:29
  • @John You may want to raise a custom flag to see if a moderator can get rid of the edit history, as the old versions of the images are still showing in that. Aug 2 at 19:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.