Hello i have been able to get a hold of my unity.3d asstet bundle files using File Browser Dialogue in my Unity GUI.
I currently use this code to attempt read all bytes from the selected file and write them to a directory
string filePath = ("my file path");
string destinationPath = "D:/projects/New folder";
byte[] fileBytes = System.IO.File.ReadAllBytes(filePath);
System.IO.File.WriteAllBytes(destinationPath,fileBytes);
but i get this error.
UnauthorizedAccessException: Access to the path 'D:/projects/New folder' is denied.
1 Answer
1
You most likely don’t have permission to write to this folder. You can try either running Unity or your executable as administrator, as mentioned by dvidunis, or change the folders permissions. If you’re on Windows, which I am guessing you are because of the file path, you can change the permissions as shown here: http://answers.microsoft.com/en-us/windows/forum/windows_vista-files/how-do-i-change-folder-and-file-permissions/465f2b42-63dd-4486-8dd1-c870290efeed
If you are on OSX or linux, open up your terminal and type
chmod +rw (path to your folder)
New to files in unity so I won't post this as an answer, but... are you sure you have permission for this folder? Try running the unity standalone as admin.
– dvidunisI thought of doing that but I have only run it from inside the game engine
– AlanimatorUmm... Try running Unity as admin? Also, what OS are you using?
– dvidunisI'm using Windows but i'm building my game to run on Linux and mac also . to run as admin is a bit too rough around the edges. so i was wondering if there was a way to write to the directory without having to run as admin.
– AlanimatorThe only way to do it without running as admin is to set the correct permissions for the folder.
– cmpgk1024