private static FindFileHandle BeginFind(string searchPattern, out WindowsNative.WIN32_FIND_DATA findData) { FindFileHandle handle = null; if (KtmTransaction.IsInTransaction) { handle = WindowsNative.FindFirstFileTransacted( searchPattern , WindowsNative.FINDEX_INFO_LEVELS.FindExInfoBasic , out findData , WindowsNative.FINDEX_SEARCH_OPS.FindExSearchNameMatch , IntPtr.Zero , 0 // 1 - case sensitive , KtmTransaction.Current.Hanlde); } else { handle = WindowsNative.FindFirstFile(searchPattern, out findData); } if (handle.IsInvalid) { int errorCode = Marshal.GetLastWin32Error(); if (errorCode != WindowsNative.ERROR_FILE_NOT_FOUND) { WindowsNative.HandleWindowsError(errorCode); } return(null); } return(handle); }