本文整理汇总了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;
}
示例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);
}
}
}
示例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();
}
示例4: RefreshDirectory
public void RefreshDirectory(FileSystemInfo e)
{
e.Refresh();
}
示例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);
}
}