Hi,
I am trying to extract zipped files using Winzip in my VB.net application and I ran into 2 stone walls.
1. How do you handle file names with spaces. See psiProcess.Argu ments
For example "My Data file Apr2007.zip"? In the example below, the
parameter pZippedFile contains the file name with spaces and the
pExtractFolder contains the folder where it should be extracted.
2. Is there anyway to get the extracted file name so that I can rename it? For
example: The zipped file is "NYC Data.zip", the extracted file is Data.txt and
It would like to rename it as NYC_Data.txt
Platform: Windows 2000
Language: VB.net
Source Code: See below
Input Used: Any zip file named as I specified in bullet point #1
Error Codes: None but the application hangs and does not extract files
however if I rename all the zip files to have no spaces it works
In addition the minimized zip file shows the zip file name as
my.zip ... everything after the first spaces is truncated.
Please note I tried quotes and brackets. I also tried to find
answers googling (sp?) and came up empty.
Any help on this would greatly be appreciated. I have been pulling out my hair
on this problem for quite awhile.
Thanks again,
LearningVB.net
I am trying to extract zipped files using Winzip in my VB.net application and I ran into 2 stone walls.
1. How do you handle file names with spaces. See psiProcess.Argu ments
For example "My Data file Apr2007.zip"? In the example below, the
parameter pZippedFile contains the file name with spaces and the
pExtractFolder contains the folder where it should be extracted.
2. Is there anyway to get the extracted file name so that I can rename it? For
example: The zipped file is "NYC Data.zip", the extracted file is Data.txt and
It would like to rename it as NYC_Data.txt
Platform: Windows 2000
Language: VB.net
Source Code: See below
Input Used: Any zip file named as I specified in bullet point #1
Error Codes: None but the application hangs and does not extract files
however if I rename all the zip files to have no spaces it works
In addition the minimized zip file shows the zip file name as
my.zip ... everything after the first spaces is truncated.
Please note I tried quotes and brackets. I also tried to find
answers googling (sp?) and came up empty.
Any help on this would greatly be appreciated. I have been pulling out my hair
on this problem for quite awhile.
Thanks again,
LearningVB.net
Code:
Public Function ZipExtract(ByVal pZippedFile As String, _ ByVal pExtractFolder As String) As Boolean '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ '~~~ This function extracts files from a zipped archive '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Dim psiProcess As New ProcessStartInfo Dim udtProc As New Process Try '~~~Set the startup information for the process. psiProcess.FileName = "C:\Program Files\WinZip\Winzip32.exe" psiProcess.WorkingDirectory = pExtractFolder psiProcess.WindowStyle = ProcessWindowStyle.Hidden psiProcess.ErrorDialog = False psiProcess.CreateNoWindow = True psiProcess.Arguments = "-min -e " & pExtractFolder & "\ '" & pZippedFile & "' " & pExtractFolder & "\" udtProc = Process.Start(psiProcess) udtProc.WaitForExit() udtProc.Close() ZipExtract = True Catch ex As DuplicateNameException '~~~ change name on the fly? Catch ex As Exception If ApplicationUtility.LoadArray(ex.Message) = True Then ZipExtract = False End If End Try End Function
Comment