Process p = new Process(); ProcessStartInfo processInfo = new ProcessStartInfo("C:\\Program Files\\WinRAR\\WinRAR.exe", "d:\\aa.rar"); p.Start(processInfo); p.Start();
可以用开源的库,sharpzip吧,在网上搜索一下,使用比较简单的
J#里面有个自解压的类库dll,可以在服务器端自解压的 忘了那个Dll的名字叫什么了
调用这个就可以了. public static void DecompressFile(string sourceFile, string destinationFile) { if (!File.Exists(sourceFile)) throw new FileNotFoundException(); using (FileStream sourceStream = new FileStream(sourceFile, FileMode.Open)) { byte[] quartetBuffer = new byte[4]; int position = (int)sourceStream.Length - 4; sourceStream.Position = position; sourceStream.Read(quartetBuffer, 0, 4); sourceStream.Position = 0; int checkLength = BitConverter.ToInt32(quartetBuffer, 0); byte[] buffer = new byte[checkLength + 100]; using (GZipStream decompressedStream = new GZipStream(sourceStream, CompressionMode.Decompress, true)) { int total = 0; for (int offset = 0; ; ) { int bytesRead = decompressedStream.Read(buffer, offset, 100); if (bytesRead == 0) break; offset += bytesRead; total += bytesRead; } using (FileStream destinationStream = new FileStream(destinationFile, FileMode.Create)) { destinationStream.Write(buffer, 0, total); destinationStream.Flush(); } } } }
或使用StartInfo来设置参数信息使用Start来启动进程
ProcessStartInfo processInfo = new ProcessStartInfo("C:\\Program Files\\WinRAR\\WinRAR.exe", "d:\\aa.rar");
p.Start(processInfo);
p.Start();
忘了那个Dll的名字叫什么了
public static void DecompressFile(string sourceFile, string destinationFile)
{
if (!File.Exists(sourceFile)) throw new FileNotFoundException();
using (FileStream sourceStream = new FileStream(sourceFile, FileMode.Open))
{
byte[] quartetBuffer = new byte[4];
int position = (int)sourceStream.Length - 4;
sourceStream.Position = position;
sourceStream.Read(quartetBuffer, 0, 4);
sourceStream.Position = 0;
int checkLength = BitConverter.ToInt32(quartetBuffer, 0);
byte[] buffer = new byte[checkLength + 100];
using (GZipStream decompressedStream = new GZipStream(sourceStream, CompressionMode.Decompress, true))
{
int total = 0;
for (int offset = 0; ; )
{
int bytesRead = decompressedStream.Read(buffer, offset, 100);
if (bytesRead == 0) break;
offset += bytesRead;
total += bytesRead;
}
using (FileStream destinationStream = new FileStream(destinationFile, FileMode.Create))
{
destinationStream.Write(buffer, 0, total);
destinationStream.Flush();
}
}
}
}
http://www.rarlab.com/rar_add.htm