我如何在压缩文件的同时压缩文件 [英] how i can copress file with keeping it's extantion

查看:131
本文介绍了我如何在压缩文件的同时压缩文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何在保持扩展名的情况下压缩文件
和文件夹中包含winrar之类的文件

感谢您的帮助

请给我代码
我曾经尝试过此代码

how i can compress file with keeping it''s extension
and folder has files like winrar

thanks for any help

plz give me code
i was try this code

FileStream sourceFile = File.OpenRead(@"C:\f.txt");
FileStream destFile = File.Create(@"C:\sample.zip");

GZipStream compStream = new GZipStream(destFile, CompressionMode.Compress);

try
{
    int theByte = sourceFile.ReadByte();
    while (theByte != -1)
    {
        compStream.WriteByte((byte)theByte);
        theByte = sourceFile.ReadByte();
    }
}
finally
{
    compStream.Dispose();
}


如何保存扩展名?

[edit]添加了代码块以保留格式-OriginalGriff [/edit]


how i can save with extension ??

[edit]Code block added to preserve formatting - OriginalGriff[/edit]

推荐答案

有一个示例方法
There is an example of how to do it here[^] - just click "cancel" when it asks you to login.


这篇关于我如何在压缩文件的同时压缩文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆