上传文件压缩后没有后缀名
爱捉弄你 2009-10-13 06:19:27 上传文件压缩后没有后缀名
public static void CompressFile(string sourceFile, string destinationFile)
{
if (!File.Exists(sourceFile)) throw new FileNotFoundException();
using (FileStream sourceStream = new FileStream(sourceFile, FileMode.Open, FileAccess.Read, FileShare.Read))
{
byte[] buffer = new byte[sourceStream.Length];
int checkCounter = sourceStream.Read(buffer, 0, buffer.Length);
if (checkCounter != buffer.Length) throw new ApplicationException();
using (FileStream destinationStream = new FileStream(destinationFile, FileMode.OpenOrCreate, FileAccess.Write))
{
using (GZipStream compressedStream = new GZipStream(destinationStream, CompressionMode.Compress, true))
{
compressedStream.Write(buffer, 0, buffer.Length);
}
}
}
}
适用上面的代码 上传文件 到制定的地方 后解压开 没有后缀名
是代码本身的问题么......
....大家有更好的代码么 有的话分享下....谢谢啦....
....小弟在线等