【VB.NET】LINQ友の会【C#, C♯, C#】at TECH
【VB.NET】LINQ友の会【C#, C♯, C#】 - 暇つぶし2ch38:35
08/02/15 11:52:15
>>35-37の応用で、ファイルの重複を検出するコードをLINQでコンパクトに書いてみます。
次のメソッドが存在するという前提です。

static string GetMD5String(string filename)
{
  using (System.Security.Cryptography.MD5CryptoServiceProvider md5
    = new System.Security.Cryptography.MD5CryptoServiceProvider())
  {
    byte[] data = System.IO.File.ReadAllBytes(filename);
    byte[] hash = md5.ComputeHash(data);

    StringBuilder buf = new StringBuilder();
    foreach (byte b in hash)
    {
      buf.AppendFormat("{0:x2}", b);
    }

    return buf.ToString();
  }
}


次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch