Click here to Skip to main content
15,890,947 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted
Updated 23-May-17 6:13am
Comments
[no name] 23-May-17 11:19am    
Find out what is preventing you from creating the folders then you can figure out a solution.
Maciej Los 23-May-17 11:34am    
Run your programme with administrative privileges (right-click on executable file).

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 the Properties -> 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.
 
Share this answer
 
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.
 
Share this answer
 
v2
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.
 
Share this answer
 
The solution to this is to install the program to the Program Files folder (or a sub-folder of it)

Once this is done, the program can create folders/files anywhere on the PC (and network maybe?)

If MS believe this is a good security measure I disagree...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900