溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶(hù)服務(wù)條款》

VB.NET如何實(shí)現(xiàn)壓縮和解壓縮

發(fā)布時(shí)間:2021-12-02 09:51:36 來(lái)源:億速云 閱讀:759 作者:小新 欄目:編程語(yǔ)言

這篇文章主要為大家展示了“VB.NET如何實(shí)現(xiàn)壓縮和解壓縮”,內(nèi)容簡(jiǎn)而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領(lǐng)大家一起研究并學(xué)習(xí)一下“VB.NET如何實(shí)現(xiàn)壓縮和解壓縮”這篇文章吧。

VB.NET壓縮和解壓縮實(shí)現(xiàn)代碼:

PublicEnumZip  Zip=0'壓縮  UnZip=1'解壓縮  EndEnum  '壓縮、解壓縮  PublicFunctionZipFile(ByValinDirPathAsString,OptionalByVal_zipAsZip=Zip.Zip,_  OptionalByValstrFileNameAsString="C:\BACKUP")AsBoolean  DimInfoAsNewInformation  DimPrintMessageAsNewErrorinf  DimstrCommandAsString  If_zip=Zip.ZipThen  DimdirectoryEntriesAsString()  directoryEntries=System.IO.Directory.GetFileSystemEntries(inDirPath)  DimstrFileAsString,strFileAllAsString  ForEachstrFileIndirectoryEntries  strFileAllstrFileAll=strFileAll&"-ep1"&strFile  Next  DimstrPassAsString=InputBox(Info.NOR_InputPassword,Info.NOR_PasswordInput)  IfstrPass.Length>0Then  strCommand="winrarA-hp"+strPass+"-ep1"  Else  strCommand="winrarA-ep1" EndIf  strCommandstrCommand=strCommand&Space(1)&strFileName&Space(1)&strFileAll  Try  IfSystem.IO.File.Exists(strFileName)Then  IfMsgBox(Info.NOR_ReplaceFile,_  MsgBoxStyle.OKCancel+_  MsgBoxStyle.Information,Info.NOR_Prompt)=MsgBoxResult.CancelThen  ReturnFalse  Else  Shell(strCommand,AppWinStyle.NormalFocus,True)  EndIf  Else  Shell(strCommand,AppWinStyle.NormalFocus,True)  EndIf  MsgBox(Info.SUC_ZipBackSuccess,MsgBoxStyle.OKOnly+MsgBoxStyle.Information,Info.NOR_Prompt)  ReturnTrue  Catch  PrintMessage.WriteErr("Cls_Common->ZipFile",Info.ERR_ZipBackError)  MsgBox(Info.ERR_ZipBackError,MsgBoxStyle.OKOnly+MsgBoxStyle.Information,Info.NOR_Prompt)  ReturnFalse  EndTry  Else  DimOpenDialogAsNewOpenFileDialog  OpenDialog.Filter="還原壓縮數(shù)據(jù)*.rar|*.rar" IfOpenDialog.ShowDialog=DialogResult.CancelThen  OpenDialog.Dispose()  ReturnFalse  EndIf  strFileName=OpenDialog.FileName  DimstrRePassAsString=InputBox(Info.NOR_InputPassword,Info.NOR_PasswordInput)  IfstrRePass.Trim.Length>0Then  strCommand="winrarX-hp"+strRePass.Trim+"-o+-inul-ep2"  Else  strCommand="winrarX-o+-inul-ep2" EndIf  strCommandstrCommand=strCommand&Space(1)&strFileName&Space(1)&Application.StartupPath  OpenDialog.Dispose()  Try  Shell(strCommand,AppWinStyle.NormalFocus,True)  MsgBox(Info.SUC_ZipRevertSuccess,MsgBoxStyle.OKOnly+MsgBoxStyle.Information,Info.NOR_Prompt)  ReturnTrue  Catch  PrintMessage.WriteErr("Cls_Common->ZipFile",Info.ERR_ZipRevertError)  MsgBox(Info.ERR_ZipRevertError,MsgBoxStyle.OKOnly+MsgBoxStyle.Information,Info.NOR_Prompt)  ReturnFalse  EndTry  EndIf  'Debug.Write(strCommand)  EndFunction

你的應(yīng)用程序的bin下要有一個(gè)winrar的可執(zhí)行文件.

以上是“VB.NET如何實(shí)現(xiàn)壓縮和解壓縮”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道!

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI