summaryrefslogtreecommitdiff
path: root/src/mscorlib/src/System/IO/File.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/mscorlib/src/System/IO/File.cs')
-rw-r--r--src/mscorlib/src/System/IO/File.cs27
1 files changed, 20 insertions, 7 deletions
diff --git a/src/mscorlib/src/System/IO/File.cs b/src/mscorlib/src/System/IO/File.cs
index 4aba148..da962f6 100644
--- a/src/mscorlib/src/System/IO/File.cs
+++ b/src/mscorlib/src/System/IO/File.cs
@@ -150,13 +150,16 @@ namespace System.IO
// Remove trialing slash since this can cause grief to FindFirstFile. You will get an invalid argument error
String tempPath = path.TrimEnd(new char[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar });
+#if !PLATFORM_UNIX
// For floppy drives, normally the OS will pop up a dialog saying
// there is no disk in drive A:, please insert one. We don't want that.
- // SetErrorMode will let us disable this, but we should set the error
+ // SetThreadErrorMode will let us disable this, but we should set the error
// mode back, since this may have wide-ranging effects.
- int oldMode = Win32Native.SetErrorMode(Win32Native.SEM_FAILCRITICALERRORS);
+ uint oldMode;
+ bool errorModeSuccess = Interop.Kernel32.SetThreadErrorMode(Interop.Kernel32.SEM_FAILCRITICALERRORS, out oldMode);
try
{
+#endif
bool error = false;
SafeFindHandle handle = Win32Native.FindFirstFile(tempPath, findData);
try
@@ -197,31 +200,41 @@ namespace System.IO
}
}
}
+#if !PLATFORM_UNIX
}
finally
{
- Win32Native.SetErrorMode(oldMode);
+ if (errorModeSuccess)
+ Interop.Kernel32.SetThreadErrorMode(oldMode, out oldMode);
}
+#endif
// Copy the information to data
data.PopulateFrom(findData);
}
else
{
+ bool success = false;
+
+#if !PLATFORM_UNIX
// For floppy drives, normally the OS will pop up a dialog saying
// there is no disk in drive A:, please insert one. We don't want that.
- // SetErrorMode will let us disable this, but we should set the error
+ // SetThreadErrorMode will let us disable this, but we should set the error
// mode back, since this may have wide-ranging effects.
- bool success = false;
- int oldMode = Win32Native.SetErrorMode(Win32Native.SEM_FAILCRITICALERRORS);
+ uint oldMode;
+ bool errorModeSuccess = Interop.Kernel32.SetThreadErrorMode(Interop.Kernel32.SEM_FAILCRITICALERRORS, out oldMode);
try
{
+#endif
success = Win32Native.GetFileAttributesEx(path, GetFileExInfoStandard, ref data);
+#if !PLATFORM_UNIX
}
finally
{
- Win32Native.SetErrorMode(oldMode);
+ if (errorModeSuccess)
+ Interop.Kernel32.SetThreadErrorMode(oldMode, out oldMode);
}
+#endif
if (!success)
{