Beispiel #1
0
 /// <summary>
 /// 使用文件路径和文件信息和哈希选项初始化 <see cref="FileInfoAndHash"/> 类的新实例。
 /// </summary>
 /// <param name="filePath">文件路径。</param>
 /// <param name="infoFields">要显示的文件信息。</param>
 /// <param name="hashTypes">要计算的文件哈希值的类型。</param>
 /// <param name="hashFormat">文件哈希值的字符串格式。</param>
 /// <exception cref="Exception">打开文件时出现错误。</exception>
 public FileInfoAndHash(string filePath, FileInfoFields infoFields,
                        FileHashTypes hashTypes, BytesFormat hashFormat)
     : base(filePath, hashTypes, hashFormat)
 {
     this.FileInfo   = new FileInfo(filePath);
     this.InfoFields = infoFields;
     this.InfoNames  = EnumHelper.GetNames(InfoFields);
 }
Beispiel #2
0
 /// <summary>
 /// 使用文件和哈希值类型初始化 <see cref="FileHash"/> 的实例。
 /// </summary>
 /// <param name="filePath">文件路径。</param>
 /// <param name="hashTypes">要计算的文件哈希值的类型。</param>
 /// <param name="hashFormat">文件哈希值的字符串格式。</param>
 /// <exception cref="Exception">打开文件时出现错误。</exception>
 public FileHash(string filePath,
                 FileHashTypes hashTypes, BytesFormat hashFormat)
 {
     this.FilePath     = filePath;
     this.HashTypes    = hashTypes;
     this.HashFormat   = hashFormat;
     this.HashNames    = EnumHelper.GetNames(hashTypes);
     this.HashingFiles = new ConcurrentDictionary <string, Stream>();
     this.HashingTasks = new ConcurrentDictionary <string, Task>();
     this.HashBytes    = new ConcurrentDictionary <string, byte[]>();
 }