Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access denied on file write #18

Open
Jamminroot opened this issue Mar 13, 2023 · 3 comments
Open

Access denied on file write #18

Jamminroot opened this issue Mar 13, 2023 · 3 comments

Comments

@Jamminroot
Copy link
Owner

System.UnauthorizedAccessException: Access to the path 'C:\DEV\uMMORPG2D\Desktop.ini' is denied.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.StreamWriter.CreateFile(String path, Boolean append, Boolean checkHost)
   at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize, Boolean checkHost)
   at System.IO.File.InternalWriteAllText(String path, String contents, Encoding encoding, Boolean checkHost)
   at System.IO.File.WriteAllText(String path, String contents, Encoding encoding)
   at intag.FileUtils.AssignTagsToFolder(String folder, HashSet`1 tags) in C:\DEV\intag\intag\FileUtils.cs:line 58
   at intag.FileUtils.AssignTags(Dictionary`2 objectTags) in C:\DEV\intag\intag\FileUtils.cs:line 29
   at intag.MainForm.FormDeactivate(Object sender, EventArgs e) in C:\DEV\intag\intag\intag_form.cs:line 183
   at System.Windows.Forms.Form.OnDeactivate(EventArgs e)
   at System.Windows.Forms.Form.set_Active(Boolean value)
   at System.Windows.Forms.Form.WmActivate(Message& m)
   at System.Windows.Forms.Form.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
@jbrown1597
Copy link

I know you've probably moved on, but incase youre still looking for a solution, it is 100% a windows permissions problem. I can help you if you like, it's fairly straightforward.

@jbrown1597
Copy link

All of these steps are performed within the (File > Right click > Properties > Security tab)

  1. Edit > Add > Object name: "Users" (no quotes) > OK > Tick allow for "Full Control" > Apply > OK

  2. Advanced > Owner > Change > "Users" (no quotes) > Tick 'Replace owner on subcontainers & objects' > Apply > OK

  3. Advanced > Add > Select principal > "Users" (no quotes)" > Apply > OK > Full control > Add files & subdirectories > Allow > OK

Presto! Now, all files in said folder will have complete write & read access.

I came across this solution whilst trying to figure out how to display xmp-dc metadata (photo & video tags) within File explorer.

HOW IT SHOULD LOOK - Copy

NOTE: If the file/folder already has tons of duplicate Principal entries (under Security > Advanced) - it will help to get a "fresh start" by pressing 'Disable inheritances' on each Principal, and then finally ticking 'Replace all child objects permissions with ...' > OK. (I forget, but I THINK you may need to re-grant yourself Full permissions real quick after replacing all child permissions)

@Jamminroot
Copy link
Owner Author

Hey! Really appreciate your effort highlighting this. Yeah, that fixes the root of the problem. The issue, however, was created when I noticed that app crashed, instead of (at least) ignoring the problem.

I did not quite move on, but working on something else, so I just left issues unresolved, so that people can show interest in resolving specific problems within the app. If enough people bring the problem up, I'll spend more time resolving it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants