當前位置: 首頁>>代碼示例>>C#>>正文


C# FileSystemInfo.Refresh方法代碼示例

本文整理匯總了C#中System.IO.FileSystemInfo.Refresh方法的典型用法代碼示例。如果您正苦於以下問題:C# FileSystemInfo.Refresh方法的具體用法?C# FileSystemInfo.Refresh怎麽用?C# FileSystemInfo.Refresh使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.IO.FileSystemInfo的用法示例。


在下文中一共展示了FileSystemInfo.Refresh方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: IsAvailable

        /// <summary>
        /// Gets a value indicating if the FileSystemInfo object is currently available
        /// </summary>
        /// <param name="fsInfo"></param>
        /// <param name="recordedSerial">if a serial is specified the return value is more reliable.</param>
        /// <returns></returns>
        public static bool IsAvailable(FileSystemInfo fsInfo, string recordedSerial)
        {
            // Get Drive Information
              DriveInfo driveInfo = GetDriveInfo(fsInfo);

              // Refresh the object information (important)
              fsInfo.Refresh();

              // Check if the file exists
              bool fileExists = fsInfo.Exists;

              // Do we have a logical volume?
              if (driveInfo != null && fileExists)
              {
            string currentSerial = driveInfo.GetVolumeSerial();
            // if we have both the recorded and the current serial we can do this very exact
            // by checking if the serials match
            if (!String.IsNullOrEmpty(recordedSerial) && !String.IsNullOrEmpty(currentSerial))
              // return the exact check result
              return (currentSerial == recordedSerial);
              }

              // return the simple check result
              return fileExists;
        }
開發者ID:drtak34,項目名稱:my-films,代碼行數:31,代碼來源:DeviceManager.cs

示例2: RemoveReadOnlyFlagRecursive

 private void RemoveReadOnlyFlagRecursive(FileSystemInfo info) {
     info.Refresh();
     if (info is FileInfo) {
         new FileInfoWrapper(info as FileInfo).ReadOnly = false;
     } else if (info is DirectoryInfo) {
         new DirectoryInfoWrapper(info as DirectoryInfo).ReadOnly = false;
         foreach (var child in (info as DirectoryInfo).GetFileSystemInfos()) {
             this.RemoveReadOnlyFlagRecursive(child);
         }
     }
 }
開發者ID:OpenDataSpace,項目名稱:CmisSync,代碼行數:11,代碼來源:FileSystemWrapperTests.cs

示例3: Delete

 /// <summary>
 /// Deletes the file or directory if it exists.
 /// </summary>
 /// <param name="info">FileInfo or DirectoryInfo instance</param>
 public void Delete(FileSystemInfo info)
 {
     if (info.Exists)
     info.Delete();
      info.Refresh();
 }
開發者ID:AnnieBougie,項目名稱:CVS-Library-Net,代碼行數:10,代碼來源:ReaderWriter.cs

示例4: RefreshDirectory

 public void RefreshDirectory(FileSystemInfo e)
 {
     e.Refresh();
 }
開發者ID:wegorich,項目名稱:UltimateCommander-WPF-file-Manager,代碼行數:4,代碼來源:UFileSystem.cs

示例5: setAttributes

 private void setAttributes(FileSystemInfo fi, ZipEntry entry)
 {
     DateTime? entryTimeUtc = getEntryTimeUtc(entry);
     if (entryTimeUtc != null)
         fi.LastWriteTimeUtc = entryTimeUtc.Value;
     if (isDos(entry) && (entry.ExternalFileAttributes != -1))
     {
         const FileAttributes mask = (FileAttributes.Archive | FileAttributes.Normal | FileAttributes.ReadOnly | FileAttributes.Hidden | FileAttributes.System);
         var entryAttributes = (FileAttributes) entry.ExternalFileAttributes;
         fi.Refresh();
         fi.Attributes = (fi.Attributes & ~mask) | (entryAttributes & mask);
     }
 }
開發者ID:xsharper,項目名稱:xsharper,代碼行數:13,代碼來源:UnZip.cs


注:本文中的System.IO.FileSystemInfo.Refresh方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。