当前位置: 首页>>代码示例>>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;未经允许,请勿转载。