ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/RomCheater/trunk/RomCheater.UserSettingsSupport/FileUtil.cs
Revision: 722
Committed: Tue Jun 18 19:18:05 2013 UTC (9 years, 11 months ago) by william
File size: 1048 byte(s)
Log Message:

File Contents

# Content
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 }