In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the knowledge of "how to implement C # calling dynamic unlha32.dll to decompress the package file of Lha suffix". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
The copy code is as follows:
Public class LhaUtity
{
/ get the version of DLL
[DllImport ("unlha32")]
Private static extern UInt16 UnlhaGetVersion ()
/ / /
/ 'get the implementation of DLL
/ / /
/ / whether it is successful or not
[DllImport ("unlha32")]
Private static extern Boolean UnlhaGetRunning ()
/ / /
/ / 'File check
/ / /
/ / /
/ / /
/ / /
[DllImport ("unlha32")]
Private static extern Boolean UnlhaCheckArchive (String szFileName, Int32 iMode)
/ / /
/ / decompress the file
/ / /
/ / /
/ / /
/ / /
/ / /
/ / /
[DllImport ("unlha32")]
Private static extern int Unlha (int hwnd, string szCmdLine, string szOutput, int dwSize)
/ / /
/ / Files that need to be extracted
/ / /
/ / decompress the file path
/ / decompress to the path
/ / whether to delete or not
Public static bool UnCompress (string archiveFile, string extractDir,bool isDeleteFile)
{
String extractFullPath = string.Empty
String startPath = AppDomain.CurrentDomain.BaseDirectory
If (! System.IO.File.Exists (archiveFile))
{
/ / decide whether to save the files that need to be unzipped
Throw new Exception (string.Format ("{0} that needs to be extracted does not exist", archiveFile))
}
Try
{
UInt16 ver = LhaUtity.UnlhaGetVersion ()
}
Catch (Exception ex)
{
Throw new Exception ("Unlha32.dll file not found")
}
If (UnlhaGetRunning ())
{
Throw new Exception ("DLL is executing")
}
If (! UnlhaCheckArchive (archiveFile, 0))
{
Throw new Exception ("File cannot be extracted")
}
/ / the path of decompression
If (string.IsNullOrEmpty (extractDir))
{
ExtractFullPath = string.Format (@ "{0} {1}\", startPath,archiveFile.Substring (archiveFile.LastIndexOf ("\") + 1 Magneto archiveFile.IndexOf (".lha")-1-archiveFile.LastIndexOf ("\")
}
Else
{
ExtractFullPath = extractDir
}
If (! System.IO.Directory.Exists (extractFullPath))
{
System.IO.Directory.CreateDirectory (extractFullPath)
}
Int ret = Unlha (0, string.Format ("x\" {0}\ "\" {1}\ ", archiveFile, extractFullPath), null, 0)
If (ret! = 0)
{
If (ret = = 32800)
{
Throw new Exception ("File unzipping cancel")
}
Else
{
Throw new Exception ("abnormal end of file extraction")
}
}
Else
{
If (isDeleteFile)
{
System.IO.File.Delete (archiveFile)
}
Return true
}
}
}
This is the end of the content of "how to implement C # calling dynamic unlha32.dll to decompress the package file of Lha suffix". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.