- Home /
FileStream requires network to open local file?
Ok, this is a strange one. The following code works absolutely fine if, and only if, there is a valid internet connection. I am using the code below to open a local file that does exist on iOS devices. With WiFi on it works, with WiFi off it crashes triggering the WTF exception. Is there any way to stop this madness! Why does FileStream appear to need a network connection?
public bool Load(string pathToLoadFrom)
{
if (!File.Exists(pathToLoadFrom)) {
return false;
}
try {
using (FileStream fs = new FileStream(pathToLoadFrom, FileMode.Open))
{
try {
//Use XmlSerializer to deserialize file
}
catch( Exception e ) {
Debug.LogError("Failed to load file " + pathToLoadFrom);
Debug.LogError(e.Message);
}
fs.Close();
}
}
catch (Exception e) {
Debug.Log("WTF: FileStream bork: " + e.Message);
return false;
}
}
The exception that get printed out is Invalid parameter which is not too helpful.
are you generating that path via Application.persistentDataPath?
Yes, and it is passing the File.Exists test, and it works when there is a WiFi connection.
Your answer
Follow this Question
Related Questions
NullReferenceException - With Network PlayerSpawn 0 Answers
ArgumentException: Getting control 2's position in a group with only 2 controls when doing mouseDown 1 Answer
My project is crashing in the Build, but not in the Editor 0 Answers
RPC a lot of lags (Photon) 0 Answers
Network animation sync, problem. -1 Answers