Hello! I am dealing with an issue with my app. I basically can’t load my sentis model in specific conditions.
When I install and run the app in a protected folder such as Program Files, programs don’t have write access by default which makes sense. So I noticed my sentis model isn’t being loaded since its access is denied by Windows. But if I launch the app in Unity or in a folder with more access such as the Download folder, I don’t have this issue and everything is working perfectly. FYI, my sentis model is located in the StreamingAssets and is being loaded like so:
ModelLoader.Load(Path.Combine(Application.streamingAssetsPath, ModelName + ".sentis"))
I tried to investigate and I realized Sentis is loading the model like so:
public static Model Load(string path)
{
using var fileStream = File.Open(path, FileMode.Open);
return Load(fileStream);
}
And then calls this:
public static FileStream Open(string path, FileMode mode)
{
return Open(path, mode, (mode == FileMode.Append) ? FileAccess.Write : FileAccess.ReadWrite, FileShare.None);
}
Since we call File.Open
with filemode=FileMode.Open
, then fileAccess=FileAccess.ReadWrite
. I don’t understand why Write access is required to read the file.
Unless I’m completely wrong, am I missing something ?
I can’t really get over this issue unless I run the app as admin.
Thank you in advance,
Matteo