如何解压Cab文件,Microsoft真是好,只要你能想到的,Microsoft基本上都已经封装好,只需要调用里面方法就好了
Download wix3.0 and Install it
then you will have new dll
Microsoft.Deployment.Compression and Microsoft.Deployment.Compression.Cab
in Project>>Add Refernce>>.net tab
add reference to those dll 's in your application and then
Write Code like below
using Microsoft.Deployment.Compression.Cab;
internal string[,] ExtractCabFile(string FullPath, string [,] guidlist)
{
string rawxmlOutputfolder = null;
FileInfo cabFile = new FileInfo(FullPath);
if (!Directory.Exists(TestCacheFolder))
{
Directory.CreateDirectory(TestCacheFolder);
}
DirectoryInfo dir = new DirectoryInfo(TestCacheFolder);
string destname = string.Format(@"{0}/{1}", dir.FullName, cabFile.Name);
if (!TryCopy(FullPath, destname))
{
return null;
}
cabFile = new FileInfo(destname);
if (cabFile.FullName.ToLower().EndsWith("cab"))
{
dir = new DirectoryInfo(TestCacheFolder);
rawxmlOutputfolder = string.Format(@"{0}/" + Path.GetFileNameWithoutExtension(FullPath), dir.FullName);
if (!Directory.Exists(rawxmlOutputfolder))
{
Directory.CreateDirectory(rawxmlOutputfolder);
}
DirectoryInfo dirextra = new DirectoryInfo(rawxmlOutputfolder);
CabInfo cab = new CabInfo(cabFile.FullName);
foreach (var item in cab.GetFiles())
{
string destFileNameExtracted = string.Format("{0}//{1}", dirextra.FullName, item.Name);
cab.UnpackFile(item.Name, destFileNameExtracted);
}
}
return discovCab.DiscoverGUIDCab(rawxmlOutputfolder, guidlist);
}