本文整理匯總了C#中System.IO.BufferedStream.FlushAsync方法的典型用法代碼示例。如果您正苦於以下問題:C# BufferedStream.FlushAsync方法的具體用法?C# BufferedStream.FlushAsync怎麽用?C# BufferedStream.FlushAsync使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.IO.BufferedStream
的用法示例。
在下文中一共展示了BufferedStream.FlushAsync方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: CalculateMD5Hash
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);
}
}