1

I have a .NET Framework program that needs to write and read some data, stored in 2 different .txt files. When I open manually the program (by double-clicking on the .exe file) it works just fine. However, when I add the program into the start-up folder (C:\Users[username]\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup) and reboot my PC it throws a "access denied exception" and it shows up a different path. Can someone help me with that?

paths error

Translation of the error: Exception is not handled by the application. Click on continue to ignore the error and to try to continue anyway. Click on Close to immediately close the application.

Access to the path C:\Windows\system32\timeUsage.txt denied.

Shloime Rosenblum
  • 927
  • 11
  • 26
Liuk23
  • 58
  • 7
  • 3
    Looks like you're trying to write to a file in system32 which is a terrible idea. – DavidG Sep 09 '21 at 19:20
  • 1
    Yeah, but why is he trying to write in system32 if I wrote another path (see first photo) – Liuk23 Sep 09 '21 at 19:24
  • It could be a rights issue. Try changing your Start menu link to `Run as Administrator`. – eglease Sep 09 '21 at 19:28
  • Could it be this https://stackoverflow.com/questions/42436117/c-sharp-error-access-to-the-path-c-windows-system32-com-dmp-is-denied-when-wi?rq=1 ? – eglease Sep 09 '21 at 19:32
  • 1
    You are probably writing a relative path in your program and when you double click the program it writes to a file in that directory but when you start the program from start up it starts the program in the system32 directory and it tries to write in that directory which you don't have permissions to write to unless as admin – Shloime Rosenblum Sep 09 '21 at 19:56
  • I've read and tried your solutions but it didn't work. I decided to create a directory in the Documents folder and save my files there (that worked, but don't know why). Thank you guys anyway! – Liuk23 Sep 10 '21 at 15:19
  • Please don't embed code or error messages as images. Instead, paste them as text and format them using Markdown. That will make them easier to read and, if necessary, copy. – Jeremy Caney Sep 15 '21 at 19:11

0 Answers0