Please note that we will be performing routine server maintenance on November 23rd. Your experience may be temporarily limited on the Audiokinetic website and Wwise Launcher for a period of 48 hours.

Community Q&A

Where Wwise users help each other out!

Audiokinetic's Community Q&A is the forum where Wwise users ask and answer questions within the Wwise community. Contact Sales if your project requires a support plan.

Unity player build error with UnauthorizedAccessException:

0 votes
When making a standalone player build in Unity for our windows project, after building once and doing a second build, I get the following:

UnauthorizedAccessException: Access to the path "D:\myCoolProject\Assets\StreamingAssets\Audio\GeneratedSoundBanks\Windows\Init.bnk" is denied.

I assume that these files are copied from the wwise project folder and they are indeed read only because they are checked into perforce.  I know why the files need to get copied, but they problem is if they exist there already from a previous build (and are marked read only as they are because they were copied from the wwiseProject folder to the StreamingAssets folder with the read only attribute set because they are checked into perforce).  Does wwise not handle this particular situation?
asked May 8 in General Discussion by Mark A. (130 points)

1 Answer

0 votes
Best answer

We experienced the exact same issue and resolved it by changing 2 files:
In AkUtitlies around line 590:

var files = dir.GetFiles();
foreach (var file in files)
            var temppath = System.IO.Path.Combine(destDirName, file.Name);
            //Edit by Shanghai Vancouver Film School Game Design

            System.IO.FileInfo fileInfo = new System.IO.FileInfo(temppath);
            if (fileInfo.Exists)
                fileInfo.IsReadOnly = false;

            System.IO.FileInfo secondFileInfo = file.CopyTo(temppath, true);
            secondFileInfo.IsReadOnly = false;

And AkBuildPreprocessor around line 129:

//Edit by Shanghai Vancouver Film School Game Design
System.IO.DirectoryInfo dirInfo = new System.IO.DirectoryInfo(destinationFolder);

if (dirInfo.Exists)
      foreach (System.IO.FileInfo f in dirInfo.GetFiles())
            f.IsReadOnly = false;
System.IO.Directory.Delete(destinationFolder, true);
UnityEngine.Debug.Log("WwiseUnity: Deleting streaming assets folder <" + destinationFolder + ">");

Hope it helps!

answered Jul 11 by SHVFS G. (440 points)
selected Jul 12 by Mark A.
Thanks.  Was pleased to see this.  It didn't occur to me at the time to look in the cs code to fix this, but this is a good idea.  I wound up solving this myself by marking the wwise files as +w so they were always writable