This project is read-only.

Files with Spaces or special Characters in the name.....

Aug 26, 2010 at 3:02 PM

Thanks for a great library first off :-)

I am having an issue where any attempts to add files with spaces in the name is failing miserably.  Folders are working fine, regardless but files I can't seem to figure out how to rectify the problem. I am by all accounts a novice to VB 2010 so this may be a self induced problem from poor coding practise :-)   but i don't know.

Here is an example:

Private Sub RunSingleArchiveSave(ByVal Colname As ListBox.SelectedObjectCollection, ByVal Zipfolder As String, ByVal ArchiveName As String)
        PictureBox2.Visible = True
             Using zip1 As ZipFile = New ZipFile()
                With zip1
                    If ComboBox3.Text = "06 = Default" Then .CompressionLevel = CompressionLevel.Default
                    If ComboBox3.Text = "09 = Best Compression" Then .CompressionLevel = CompressionLevel.BestCompression
                    If ComboBox3.Text = "01 = Fastest" Then .CompressionLevel = CompressionLevel.BestSpeed
                    If ComboBox3.Text = "02" Then .CompressionLevel = CompressionLevel.Level2
                    If ComboBox3.Text = "03" Then .CompressionLevel = CompressionLevel.Level3
                    If ComboBox3.Text = "04" Then .CompressionLevel = CompressionLevel.Level4
                    If ComboBox3.Text = "05" Then .CompressionLevel = CompressionLevel.Level5
                    If ComboBox3.Text = "07" Then .CompressionLevel = CompressionLevel.Level7
                    If ComboBox3.Text = "08" Then .CompressionLevel = CompressionLevel.Level8
                    .Comment = "The Canadian Archiver (  " & vbCrLf & TextBox2.Text
                    .Password = MaskedTextBox1.Text
                    .TempFileFolder = Zipfolder

                    Me._entriesToZip = zip1.EntryFileNames.Count
                    AddHandler zip1.SaveProgress, New EventHandler(Of SaveProgressEventArgs)(AddressOf Me.zip1_SaveProgress2)
                End With

                Dim SaveToDirectoryPath As String = Zipfolder

                For Each item In Colname
                    Dim SpaceLessName As String = Replace(item.ToString, " ", "_")
                    zip1.AddSelectedFiles(item.tostring, Zipfolder, "", True)

                '  zip1.AddItem(Zipfolder & "\" & ZIPName)
                Dim endresult As String = ((SaveToDirectoryPath.ToString & "\" & (ArchiveName)))
                ' End If
            End Using


so if i replace the space in the file with let's say "_" i then need to do this to the file also (obviously) which I can do but would rather not have the act of archiving result in file modification. I have tried adding single and double quotes to encapsulate but then I get path errors.  to note i have 2 textboxes, one with a single quote (SQ) and one with a double quote(Q) i use these to add the quotes so perhaps that is my issue but it seems to work with everything else (ie: dim whatever as string = ( q.text & "whatever" & q.text) )


so i am hoping someone could tell me or show me whether i am indeed causing my own grief or if this is a problem of some other sort.


I also thought about modifying the workflow in the code so that when a file is found with spaces in the name a directory is created by that name in the file system and the file added in there and then zipped, as adding a directory to a zip with spaces in the name works just fine


anyways thanks for any insight that can be offered and again, thanks for this library it really is nice to not have to go knocking on chilikat's door for a zip control :-)

Aug 26, 2010 at 3:05 PM

also this is not used by the way

For Each item In Colname
                    Dim SpaceLessName As String = Replace(item.ToString, " ", "_")
                    zip1.AddSelectedFiles(item.tostring, Zipfolder, "", True)

it is like so:

For Each item In Colname
                     zip1.AddSelectedFiles(item.tostring, Zipfolder, "", True)



sorry that was some failed attempts from late last night :-)