net压缩文件夹
Ⅰ .net 压缩某个文件 再返回压缩包至本地
远程文件传输?
Ⅱ C#.net 文件压缩问题
.net有个压缩类!
Ⅲ .net/C# 中怎样查找Zip压缩包下是不是有文件夹,有的话解压,求大神解
假定你用的是sharpcompress
using(vararchive=ArchiveFactory.Open("c:\sample.zip"))
foreach(varentryinarchive.Entries)
{
if(!entry.IsDirectory)
entry.WriteToDirectory("c:\",ExtractOptions.ExtractFullPath|ExtractOptions.Overwrite);
}
上面的ExtractOptions.ExtractFullPath是表示连目录解压,如果你不需要解压时自动创建目录,直接删掉上面的ExtractOptions.ExtractFullPath就行了。
Ⅳ .net压缩文件.谁会,求指导,最好有源代码
MSDN里的例子,用GZIP方式压缩,贴给你。
至于弹出框提示选择保存地址什么的,是基本的SaveFileDialog控件,拖一个SaveFileDialog控件在窗体里(命名为saveFileDialog1),然后在按钮点击事件中写saveFileDialog1.ShowDialog(); 这个要是还不会的话,说起来就太费口舌了。
using System;
using System.IO;
using System.IO.Compression;
namespace zip
{
public class Program
{
public static void Main()
{
// Path to directory of files to compress and decompress.
string dirpath = @"c:\users\public\reports";
DirectoryInfo di = new DirectoryInfo(dirpath);
// Compress the directory's files.
foreach (FileInfo fi in di.GetFiles())
{
Compress(fi);
}
// Decompress all *.gz files in the directory.
foreach (FileInfo fi in di.GetFiles("*.gz"))
{
Decompress(fi);
}
}
public static void Compress(FileInfo fi)
{
// Get the stream of the source file.
using (FileStream inFile = fi.OpenRead())
{
// Prevent compressing hidden and
// already compressed files.
if ((File.GetAttributes(fi.FullName)
& FileAttributes.Hidden)
!= FileAttributes.Hidden & fi.Extension != ".gz")
{
// Create the compressed file.
using (FileStream outFile =
File.Create(fi.FullName + ".gz"))
{
using (GZipStream Compress =
new GZipStream(outFile,
CompressionMode.Compress))
{
// Copy the source file into
// the compression stream.
inFile.CopyTo(Compress);
Console.WriteLine("Compressed {0} from {1} to {2} bytes.",
fi.Name, fi.Length.ToString(), outFile.Length.ToString());
}
}
}
}
}
public static void Decompress(FileInfo fi)
{
// Get the stream of the source file.
using (FileStream inFile = fi.OpenRead())
{
// Get original file extension, for example
// "doc" from report.doc.gz.
string curFile = fi.FullName;
string origName = curFile.Remove(curFile.Length -
fi.Extension.Length);
//Create the decompressed file.
using (FileStream outFile = File.Create(origName))
{
using (GZipStream Decompress = new GZipStream(inFile,
CompressionMode.Decompress))
{
// Copy the decompression stream
// into the output file.
Decompress.CopyTo(outFile);
Console.WriteLine("Decompressed: {0}", fi.Name);
}
}
}
}
}
}
Ⅳ c#.net 调用rar 压缩文件+修改内容文件名
没这样试过,不行的话你用bat好了,形如
@echo off
x:\xxx\xx\winrar.exe a -afzip - m0 -ep1 1% 2%"
exit
调用的时候用你上面的代码比如filename="a.bat"; arguments=spath+ " " + filestr;
还是不行的话,你换zip格式算了,c#自带支持。
Ⅵ vb.net进行文件压缩
如果机器安装有winRar软件,就可以通过shell来借用他的功能达到压缩文件的效果;
参考代码如下:
Dim DeliveryF As String = Server.MapPath("..\Temp\DeliveryFactors.xls") '原始文件 (压缩前)
Dim TruckInfo As String = Server.MapPath("..\Temp\TruckInformation.xls")
Dim QDetail As String = Server.MapPath("..\Temp\QuotationDetail.xls")
'用shell命令调用winrar.exe创建压缩文件()
Dim winRarexe As String = "C:\Program Files\WinRAR\Rar" 'winzip 执行文件的位置
Dim wtarget As String = "C:\temp\QuotationVAComparsion.zip" '目地文件 (压缩后)
Dim command As String = winRarexe & " a " & wtarget & " " & DeliveryF & " " & TruckInfo & " " & QDetail
'这个命令你可以查看winrar的命令集
Dim retval As Double 'Shell 指令传回值
retval = Shell(command, AppWinStyle.MinimizedFocus)
Ⅶ C# .net 怎么样将多个文件进行压缩
用。net框架提供的类库就可以啊。
using System.IO.Compression;
Ⅷ asp.net实现压缩多个文件夹
你需要调用WINRAR或者7ZIP等压缩软件的内核,不过这些软件好像都没有开放内核接口代码,可以看看微软的压缩内核。
Ⅸ vb.net 如何压缩、解压缩文件
1、你先搞懂 winrar.exe 的解压参数格式,然后把winrar.exe和相关文件加入到资源文件中,然后调用 资源文件中的winrar.exe
2、弄明白rar/zip文件解压/压缩方法和格式,自己写程序 (可能会比较麻烦)