Can a program write to the root directory of a dis

2020-05-06 12:06发布

问题:

If I am not an Administrator and start a program which writes to C:\ some textfile - will I need admin rights...in Windows 7 or Vista? I see in XP there are no problems to write to any folder including system32 - but I am not sure if a program in say .NET will be able to do that without admin permissions.

回答1:

That depends on whether C:\ is a filesystem that supports permissions, and if so on the permissions set on the root directory, which can be modified by users with the correct privileges. Use GetTempPath() for temporary files, or SHGetFolderPath passing e.g. CSIDL_APPDATA



回答2:

No, you can't write to the root of disk even in Windows XP if you are not an administrator. It's just everyone works as administrator in XP; and this assumption is actually wrong.



回答3:

Yes. You won't be able to write to C:\Program Files\ or C:\Windows\, but just the root drive C:\ is fine.