- Home /
Question by
OliverAnthony · May 04, 2013 at 06:00 AM ·
securitysystem.iowindows 7
Getting UnauthorizedAccessExceotion when trying to write to a file.
I'm getting this error:
UnauthorizedAccessExceotion: Access to the path 'C:\Users\Nirn\Documents\Marble Run\Project Folder\Levels' is denied.
At this line:
System.IO.File.WriteAllText(filePath,"track"+numTracks.ToString());
I've made sure the Editor.exe has every security privilege, and I always run as administrator.
I'm running Windows 7 32 bit.
Comment
Absolutely does. I copied the file path directly from the explorer.
What's the name of the file that you are writing to? The first argument to WriteAllText
is the filename, including the path. It looks like you are trying to write numTracks
to the folder, ins$$anonymous$$d of a file in the folder.
Thankyou, adding the file name to the filePath string was all that I needed to do. I was doing "track"+numTracks.ToString() for the wrong argument.
Your answer
![](https://koobas.hobune.stream/wayback/20220613101511im_/https://answers.unity.com/themes/thub/images/avi.jpg)