public DataFile GetDataFile(FileMode mode, string path)
{
if (mode == FileMode.Open)
{
// Search all paths when opening existing files
foreach (var searchPath in searchPaths)
{
string tryPath = Path.Combine(searchPath, path);
if (File.Exists(tryPath))
return new DataFile(this, mode, tryPath, path);
}
// When not found give path to file in data folder
// Opening the data file will fail as it should because the file does not exist
return new DataFile(this, mode, Path.Combine(dataFolder, path), path);
}
else
{
// Every new file will be created in the overwite folder
return new DataFile(this, mode, Path.Combine(moOverwritePath, path), path);
}
}