在win 10上从应用程序创建子文件夹 [英] Create sub-folders from an application on win 10
问题描述
我有一个应用程序,它在主工作文件夹下创建子文件夹。这已经在XP,Vista,Win 7上运行了几年,直到最近在Win 10上运行,现在不允许创建这些文件夹。我已将权限设置为完全控制,但仍不会从应用程序创建子文件夹。我可以手动创建它们。我需要做什么才能让我的程序创建其工作子文件夹?
我尝试了什么:
设置文件夹,应用程序,所有.dll的完全控制权限
我还修改了代码以使用命令md允许手动创建子文件夹,但在应用程序中调用它仍然不起作用
I have an application which creates sub-folders under the main working folder. This has been working for some years on XP, Vista, Win 7 and until recently on Win 10, which now will not allow these folders to be created. I have set the permissions to full control but still it will not create the sub-folders from the application. I can create them manually. What do I need to do to allow my program to create its working sub-folders?
What I have tried:
Setting permissions to full control for folders, applications, all .dlls
I have also modified the code to use the command md which allows the sub-folders to be created manually but calling this in the application still does not work
推荐答案
正如我在问题的评论中提到的,你必须以管理权限运行您的可执行文件。另一种选择是创建该可执行文件的快捷方式,然后:转到属性 - >高级 - >
选中以管理员身份运行
选项。
请阅读这:如何:创建文件或文件夹(C#编程指南)| Microsoft Docs [ ^ ] .NET Framework安全性部分。
As i mentioned in the comment to the question, you have to run your executable with administrative privileges. Another option is to create a shortcut to that executable, then: go to theProperties -> Advanced ->
check "Run as administrator
" option.
Please read this: How to: Create a File or Folder (C# Programming Guide) | Microsoft Docs[^] .NET Framework Security part.
如果通过main工作文件夹你的意思是在C:\Program Files下,然后是的,你的应用程序被拒绝访问,因为Program Files下的所有东西都是普通用户的ReadOnly。
您应该使用更合适的地方放置数据文件,例如C:\ProgramData \< mycompanyname> \< myappname>。这些文件夹可由任何用户写入。
要获取ProgramData文件夹的路径,请调用 Environment.GetFolderPath() [ ^ ]并使用CommonApplicationData [ ^ ]枚举值作为参数。
你我必须构建路径的其余部分,\< mycompanyname> \< myappname>部分。使用 Path.Combine() [ ^ ]。
If by "main working folder" you mean under C:\Program Files, then yes, you're app is being denied access because everything under Program Files is ReadOnly to normal users.
You should be using a more suitable place to put data files, such as under C:\ProgramData\<mycompanyname>\<myappname>. These folders are writable by any user.
To get the path to the ProgramData folder, call Environment.GetFolderPath()[^] and use the CommonApplicationData[^] enum value as the parameter.
You'll have to build out the rest of the path, the \<mycompanyname>\<myappname> part. Use Path.Combine()[^] for that.
主工作文件夹已设置为Documents(如建议的那样)但仍无法创建子文件夹。
我试过再次以管理员身份运行没有快乐。
我们现在用MS的最新补丁更新了一台完美的Win 8 PC,现在也无法创建子文件夹...
我认为MS引入了一个严重的错误。
The main working folder has been set to the Documents (as advised) but it still cannot create sub-folders.
I have tried running as administrator again no joy.
We have now updated a perfectly working Win 8 PC with the latest patches from MS and now that too cannot create sub-folders...
I think MS have introduced a serious bug.
这篇关于在win 10上从应用程序创建子文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!