0
votes

If I create an application that writes a .txt file to C:\Users\username\Documents\file.txt. Will it work? In Windows 7 and Vista? Say...especially if I have a brand new default installation of windows 7 and then attempt to write the file file.txt to the "my documents" folder: C:\users\username\documents\file.txt. What if I create a directory with all permissions inside this folder? Or...it will work but I will get some stupid prompt message for admin privileges? thanks in advance!

3

3 Answers

2
votes

Assuming that you get the folder path correctly using Environment.GetFolderPath(), then you'll be fine.

2
votes

No, you can not assume that you have write privileges in that folder.

And please, do not create files in that folder!

The documents folder is for the user to put files there, not for applications. Use the path %appdata%\yourappname\file.txt instead.

1
votes

Yes, it should work. The user has write access to his my documents folder. This is the case even for a limited user. You won't get an admin prompt.