File creation fails in standard account (Vista)

ε祈祈猫儿з 提交于 2019-12-25 04:39:14

问题


I have created C# application, which creates a image file on Desktop. It works fine on XP and Vista (admin account) but it fails to create image file on Desktop in Vista (standard account).

Whether i have to include manifest file to the application to work properly? If i add manifest, will it work on XP without any problems?

Sorry if it is lame question. Thanks in advance.


回答1:


Make sure you're using the System.Environment.SpecialFolder class to tell you where your user's Desktop really is.




回答2:


Which folder are you trying to create the file in? The shared desktop folder or the user's desktop folder? Ordinary users cannot create shared desktop files.

You should be writing to the folder specified by the following Registry value:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Desktop



回答3:


You should have no problems creating a file on the desktop. However, that desktop might now have a different location. Are you actually trying to create a file on the Vista desktop, or are you accidentily still trying to create a file using paths from XP? Can you distill your code to a 20 line example?




回答4:


To answer your first question, in the absence of any details about the code and errors generated it sounds like the standard account doesn't have the permissions to create a file on the desktop.

Can you do it manually when logged in using the standard account? I've not got Vista installed so I can't check myself.




回答5:


I bet it's the access rights. The Vista UAC thing that comes up and asks for permission would probably be a good thing there.

Check this link for how to get UAC access:

Demand UAC elevation for an application




回答6:


With in the directory of your App give permissions to Users to take ownership and delete. This involves clicking the Advanced button within the Security Tab. Once you apply the changes you File IO should work fine.




回答7:


My suggestion is only needed if trying to do File IO within a system directory like C:\Program Files...



来源:https://stackoverflow.com/questions/949782/file-creation-fails-in-standard-account-vista

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!