I am trying to create a text file in C: using code (shown in picture) It says access is denied. Please help.
Thanks
I am trying to create a text file in C: using code (shown in picture) It says access is denied. Please help.
Thanks
The root of the C: drive is protected (On Windows Vista, 7, etc), so users cannot write to it unless the process is elevated.
Try right clicking on your compiled exe and then Run As Admin
to test this theory.
The solution is to save your file somewhere else. This may help- Lemme Tell Ya Where to Stick It and Where Should I Store my Data and Configuration Files
Or you may want to create a temp file: How can I create a temp file with a specific extension with .NET? - you should have the relevant permissions to save this file but it cannot be guaranteed.
The user, who executes the program has no rights to create a file directly into the c:\ drive.