开发者

Can an application write by default to the "My documents" folder in Windows 7?

If I create an application that writes a .txt file to C:\Users\username\Documents\file.txt. Will 开发者_Python百科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!


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


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜