简体   繁体   English

在C#中创建包含mdf文件的zip文件

[英]To create zip file that containing mdf file in C#

I have .mdf and .ldf file in my local device. 我的本地设备中有.mdf和.ldf文件。 I want to create zip that two files. 我想创建两个文件的zip文件。 I use DonetZip. 我使用DonetZip。 But it didn't show me any error and also the program is not working. 但是它没有显示任何错误,并且该程序无法正常工作。 How should I do and I want some example to zip .mdf and .ldf files. 我应该怎么做,我想一些压缩.mdf和.ldf文件的示例。

How about 怎么样

using (ZipFile zip = new ZipFile())
{
    zip.AddFile(@"C:\SomeFile.mdf");
    zip.AddFile(@"C:\SomeFile.ldf");
    zip.Save(@"C:\zippedfolder.zip");
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM