It's both racy and not necessary.
Beyond that, it will produce the wrong exception if opening the file fails for a different reason that it's missing.
This is an issue in case of bad permissions or symlink loops.
}
}
- if (access == FileAccess.Read && mode != FileMode.Create && mode != FileMode.OpenOrCreate &&
- mode != FileMode.CreateNew && !File.Exists (path)) {
- // don't leak the path information for isolated storage
- string msg = Locale.GetText ("Could not find file \"{0}\".");
- string fname = GetSecureFileName (path);
- throw new FileNotFoundException (String.Format (msg, fname), fname);
- }
-
// IsolatedStorage needs to keep the Name property to the default "[Unknown]"
if (!anonymous)
this.name = path;