我们的目的
我们是要将本地的一个文件夹里面的内容上传到服务器,但是服务器(自己搭的)那边不支持文件夹传送,故先要将文件夹压缩,再上传。项目要求越简便越好,所以压缩和上传放在一个button里面做了。
搭一个简单的测试界面
一个上传按钮,一个显示信息的label
之后就要实现压缩,以及上传的功能了
压缩
下载ICSharpCode.SharpZipLib.dll文件,放到你项目的debug(或者bin)目录下,在项目中添加引用dll文件,然后新建一个类ZipHelper.cs, 下面是类中的内容
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Diagnostics;
using ICSharpCode.SharpZipLib;
using ICSharpCode.SharpZipLib.Zip;
using ICSharpCode.SharpZipLib.Checksums;
using ICSharpCode.SharpZipLib.Core;
namespace ZipOneCode.ZipProvider
{
public class