Exemple #1
0
 public static bool Exists(string path)
 {
     using (TransactionScope scope = new TransactionScope())
     using (KtmTransactionHandle ktmTx = KtmTransactionHandle.CreateKtmTransactionHandle())
     {
         bool result = false;
         NativeMethods.WIN32_FILE_ATTRIBUTE_DATA data = new NativeMethods.WIN32_FILE_ATTRIBUTE_DATA();
         if (NativeMethods.GetFileAttributesTransacted(path, 0, out data, ktmTx))
         {
             result = NativeMethods.INVALID_FILE_ATTRIBUTES != data.FileAttributes && NativeMethods.FILE_ATTRIBUTE_DIRECTORY == (NativeMethods.FILE_ATTRIBUTE_DIRECTORY & data.FileAttributes);
         }
         scope.Complete();
         return result;
     }
 }