/[RomCheater]/trunk/RomCheater.UserSettingsSupport/FileUtil.cs
ViewVC logotype

Contents of /trunk/RomCheater.UserSettingsSupport/FileUtil.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 722 - (show annotations) (download)
Tue Jun 18 19:18:05 2013 UTC (7 years, 5 months ago) by william
File size: 1048 byte(s)

1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.Runtime.InteropServices;
6
7 namespace RomCheater.UserSettingsSupport
8 {
9 internal static class FileUtil
10 {
11
12 // Fields
13 private const int HRESULT_WIN32_FILE_NOT_FOUND = -2147024894;
14 private const int HRESULT_WIN32_PATH_NOT_FOUND = -2147024893;
15
16 // Methods
17 internal static bool FileExists(string filename, bool trueOnError)
18 {
19 UnsafeNativeMethods.WIN32_FILE_ATTRIBUTE_DATA win_file_attribute_data;
20 if (UnsafeNativeMethods.GetFileAttributesEx(filename, 0, out win_file_attribute_data))
21 {
22 return ((win_file_attribute_data.fileAttributes & 0x10) != 0x10);
23 }
24 if (!trueOnError)
25 {
26 return false;
27 }
28 int num = Marshal.GetHRForLastWin32Error();
29 return ((num != -2147024894) && (num != -2147024893));
30 }
31 }
32
33
34
35
36
37
38
39 }

  ViewVC Help
Powered by ViewVC 1.1.22