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文件解壓/壓縮方法和格式,自己寫程序 (可能會比較麻煩)