菜鸟表示一头雾水,没有中文的说明文档。也没有接口使用范例。
我把这个地址贴出来吧。
http://www.developershome.com/7-zip/sdk.asp
有空的,帮忙看看吧,点那个下载就能下载整个接口程序了,里面有C#的接口
我把这个地址贴出来吧。
http://www.developershome.com/7-zip/sdk.asp
有空的,帮忙看看吧,点那个下载就能下载整个接口程序了,里面有C#的接口
unzip : byte[] properties = new byte[5];
if (inStream.Read(properties, 0, 5) != 5)
throw (new Exception("input .lzma is too short"));
Compression.LZMA.Decoder decoder = new Compression.LZMA.Decoder();
decoder.SetDecoderProperties(properties);
if (trainStream != null)
{
if (!decoder.Train(trainStream))
throw (new Exception("can't train"));
}
long outSize = 0;
for (int i = 0; i < 8; i++)
{
int v = inStream.ReadByte();
if (v < 0)
throw (new Exception("Can't Read 1"));
outSize |= ((long)(byte)v) << (8 * i);
}
long compressedSize = inStream.Length - inStream.Position;
decoder.Code(inStream, outStream, compressedSize, outSize, null);zip :[code] if (!dictionaryIsDefined)
dictionary = 1 << 23; Int32 posStateBits = 2;
Int32 litContextBits = 3; // for normal files
// UInt32 litContextBits = 0; // for 32-bit data
Int32 litPosBits = 0;
// UInt32 litPosBits = 2; // for 32-bit data
Int32 algorithm = 2;
Int32 numFastBytes = 128; bool eos = parser[(int)Key.EOS].ThereIs || stdInMode; if (parser[(int)Key.Mode].ThereIs)
if (!GetNumber((string)parser[(int)Key.Mode].PostStrings[0], out algorithm))
IncorrectCommand(); if (parser[(int)Key.FastBytes].ThereIs)
if (!GetNumber((string)parser[(int)Key.FastBytes].PostStrings[0], out numFastBytes))
IncorrectCommand();
if (parser[(int)Key.LitContext].ThereIs)
if (!GetNumber((string)parser[(int)Key.LitContext].PostStrings[0], out litContextBits))
IncorrectCommand();
if (parser[(int)Key.LitPos].ThereIs)
if (!GetNumber((string)parser[(int)Key.LitPos].PostStrings[0], out litPosBits))
IncorrectCommand();
if (parser[(int)Key.PosBits].ThereIs)
if (!GetNumber((string)parser[(int)Key.PosBits].PostStrings[0], out posStateBits))
IncorrectCommand(); CoderPropID[] propIDs =
{
CoderPropID.DictionarySize,
CoderPropID.PosStateBits,
CoderPropID.LitContextBits,
CoderPropID.LitPosBits,
CoderPropID.Algorithm,
CoderPropID.NumFastBytes,
CoderPropID.MatchFinder,
CoderPropID.EndMarker
};
object[] properties =
{
(Int32)(dictionary),
(Int32)(posStateBits),
(Int32)(litContextBits),
(Int32)(litPosBits),
(Int32)(algorithm),
(Int32)(numFastBytes),
mf,
eos
}; Compression.LZMA.Encoder encoder = new Compression.LZMA.Encoder();
encoder.SetCoderProperties(propIDs, properties);
encoder.WriteCoderProperties(outStream);
Int64 fileSize;
if (eos || stdInMode)
fileSize = -1;
else
fileSize = inStream.Length;
for (int i = 0; i < 8; i++)
outStream.WriteByte((Byte)(fileSize >> (8 * i)));
if (trainStream != null)
{
CDoubleStream doubleStream = new CDoubleStream();
doubleStream.s1 = trainStream;
doubleStream.s2 = inStream;
doubleStream.fileIndex = 0;
inStream = doubleStream;
long trainFileSize = trainStream.Length;
doubleStream.skipSize = 0;
if (trainFileSize > dictionary)
doubleStream.skipSize = trainFileSize - dictionary;
trainStream.Seek(doubleStream.skipSize, SeekOrigin.Begin);
encoder.SetTrainSize((uint)(trainFileSize - doubleStream.skipSize));
}
encoder.Code(inStream, outStream, -1, -1, null);[/code]
dictionary = 1 << 23; Int32 posStateBits = 2;
Int32 litContextBits = 3; // for normal files
// UInt32 litContextBits = 0; // for 32-bit data
Int32 litPosBits = 0;
// UInt32 litPosBits = 2; // for 32-bit data
Int32 algorithm = 2;
Int32 numFastBytes = 128; bool eos = parser[(int)Key.EOS].ThereIs || stdInMode; if (parser[(int)Key.Mode].ThereIs)
if (!GetNumber((string)parser[(int)Key.Mode].PostStrings[0], out algorithm))
IncorrectCommand(); if (parser[(int)Key.FastBytes].ThereIs)
if (!GetNumber((string)parser[(int)Key.FastBytes].PostStrings[0], out numFastBytes))
IncorrectCommand();
if (parser[(int)Key.LitContext].ThereIs)
if (!GetNumber((string)parser[(int)Key.LitContext].PostStrings[0], out litContextBits))
IncorrectCommand();
if (parser[(int)Key.LitPos].ThereIs)
if (!GetNumber((string)parser[(int)Key.LitPos].PostStrings[0], out litPosBits))
IncorrectCommand();
if (parser[(int)Key.PosBits].ThereIs)
if (!GetNumber((string)parser[(int)Key.PosBits].PostStrings[0], out posStateBits))
IncorrectCommand(); CoderPropID[] propIDs =
{
CoderPropID.DictionarySize,
CoderPropID.PosStateBits,
CoderPropID.LitContextBits,
CoderPropID.LitPosBits,
CoderPropID.Algorithm,
CoderPropID.NumFastBytes,
CoderPropID.MatchFinder,
CoderPropID.EndMarker
};
object[] properties =
{
(Int32)(dictionary),
(Int32)(posStateBits),
(Int32)(litContextBits),
(Int32)(litPosBits),
(Int32)(algorithm),
(Int32)(numFastBytes),
mf,
eos
}; Compression.LZMA.Encoder encoder = new Compression.LZMA.Encoder();
encoder.SetCoderProperties(propIDs, properties);
encoder.WriteCoderProperties(outStream);
Int64 fileSize;
if (eos || stdInMode)
fileSize = -1;
else
fileSize = inStream.Length;
for (int i = 0; i < 8; i++)
outStream.WriteByte((Byte)(fileSize >> (8 * i)));
if (trainStream != null)
{
CDoubleStream doubleStream = new CDoubleStream();
doubleStream.s1 = trainStream;
doubleStream.s2 = inStream;
doubleStream.fileIndex = 0;
inStream = doubleStream;
long trainFileSize = trainStream.Length;
doubleStream.skipSize = 0;
if (trainFileSize > dictionary)
doubleStream.skipSize = trainFileSize - dictionary;
trainStream.Seek(doubleStream.skipSize, SeekOrigin.Begin);
encoder.SetTrainSize((uint)(trainFileSize - doubleStream.skipSize));
}
encoder.Code(inStream, outStream, -1, -1, null);
我不确定对你有用啊!我贴个方法给你看: 写个方法
public static string RunCmd(string strCmd)
{
string rInfo;
try
{
Process myProcess = new Process();
ProcessStartInfo myProcessStartInfo = new ProcessStartInfo("cmd.exe ");
myProcessStartInfo.UseShellExecute = false;
myProcessStartInfo.RedirectStandardOutput = true;
myProcess.StartInfo = myProcessStartInfo;
myProcessStartInfo.Arguments = "/c " + strCmd;
myProcess.Start();
StreamReader myStreamReader = myProcess.StandardOutput;
rInfo = myStreamReader.ReadToEnd();
myProcess.Close();
rInfo = strCmd + "\r\n " + rInfo;
return rInfo;
}
catch (Exception ex)
{
return ex.Message;
}调用这个方法RunCmd(Server.MapPath(@"7zip文件夹的路径") + "/7-Zip/7z.exe x " + "\"" + 路径和文件名(全部写出来)+ "\"" + " -o\"" + 保存的路径(全路径)+ "\"")