FlushAsync() public method

public FlushAsync ( CancellationToken cancellationToken ) : Task
cancellationToken CancellationToken
return Task
Ejemplo n.º 1
0
 public static async Task<string> CalculateMD5Hash(string sFilePath)
 {
     using (MD5CryptoServiceProvider hasher = new MD5CryptoServiceProvider())
     {
         byte[] hashvalue;
         // TODO Test perf of different buffer sizes, particularly for different file sizes (e.g. 10kb, 150kb, 500kb, 1mb, 5mb, 20mb, 50mb, 150mb, 500mb, 1gb, 2gb)
         using (var stream = new BufferedStream(File.OpenRead(sFilePath), 1200000))
         {
             // TODO Verify that async change is necessary (or maybe should be on buffered file load instead, with the following line removed?)
             await stream.FlushAsync();
             hashvalue = hasher.ComputeHash(stream);
         }
         return System.BitConverter.ToString(hashvalue);
     }
 }