トップ > Tech > CSharp > 備忘録

備忘録

ZIP関連

private void button1_Click(object sender, EventArgs e)
{
    Stopwatch watch = new Stopwatch();
    watch.Start();

    DirectoryInfo dirInfo = new DirectoryInfo("C:");
    FileInfo[] fileInfos = dirInfo.GetFiles("*.zip", SearchOption.AllDirectories);

    foreach (FileInfo fileInfo in fileInfos)
    {
        process(fileInfo.FullName);
    }

    Debug.WriteLine(watch.Elapsed);
}

private void process(string zipFilePath)
{
    FastZip fzip = new FastZip();
    fzip.ExtractZip(zipFilePath, "TEMP", string.Empty);
    string filecontent = File.ReadAllText(string.Format(@"TEMP\{0}", "test.txt"));
    filecontent = filecontent.Replace("ABC", "ZZZ");
    File.WriteAllText(string.Format(@"TEMP\{0}", "test.txt"), filecontent);
    fzip.CreateZip(zipFilePath, "TEMP", false, "");
    Directory.Delete("TEMP", true);
}
(2010/03/25 17:26:27)
4965
プロフィール

Kenz Yamada(山田研二)。1984年生。大阪。ちょっとずつ好きなプログラム作ってます。 好きなものはカメラと旅行。ガジェットや身の回り、ちょっとこだわります。 詳しくは Web mixi で。

Bookmark and Share