Click here to Skip to main content
15,890,506 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Ok, so I know this sounds like a weird question, but I am unable to select a .ZIP folder with either the FolderBrowserDialog (FBD) or the OpenFileDialog (OFD). First off the FBD does not show any .ZIP folders when using it and the OFD does show .ZIP folders but I am not sure how to handle it's path. My question would be how can I handle the OFDs ".SelectedPath"???
I could easily obtain that info with the FBD "FolderBrowserDialog1.SelectedPath", but it does not allow the selection of .ZIP folders.. So now I am trying to do the same thing with the OFD but there isn't any code for obtaining the ".SelectedPath". Here's some code that shows what I am trying to do:
VB
Private sourcePath As String
Private destPath As String

    With OpenFileDialog1
        .FileName = "DC_BACKUP"
        .Title = "Locate DC_BACKUP.zip"
        .InitialDirectory = Environment.SpecialFolder.Desktop
        .Filter = ".ZIP (*.zip) |*.zip"
        If .ShowDialog = Windows.Forms.DialogResult.OK Then
            Try
                destPath = .SelectedPath '*RIGHT HERE IS WHERE I NEED HELP FOR GETTING THE SELECTEDPATH*
                sourcePath = destPath
                Directory.CreateDirectory(Application.StartupPath + "\SavedFiles\DC_BACKUP")
                CopyDir.CopyAll(New DirectoryInfo(sourcePath), New DirectoryInfo(Application.StartupPath + "\SavedFiles\DC_BACKUP\"))
                UnZipFolder(Application.StartupPath + "\SavedFiles\DC_BACKUP\SavedFiles.zip", Application.StartupPath + "\SavedFiles\")
            Catch ex As Exception
            End Try
        End If
    End With

Any help would be greatly appreciated! :)
Posted

1 solution

use the FileName property
 
Share this answer
 
Comments
NY Andrew 12-Aug-11 23:03pm    
OH! I gotcha! I changed the "destPath = .SelectedPath" TO "destPath = .FileName" and tested it by creating a MessageBox to display the path and it worked! So I guess the problem lies within my code as to why it is not unzipping the contents of the ZIP..


Directory.CreateDirectory(Application.StartupPath + "\SavedFiles\DC_BACKUP")
CopyDir.CopyAll(New DirectoryInfo(sourcePath), New DirectoryInfo(Application.StartupPath + "\SavedFiles\DC_BACKUP\"))
UnZipFolder(Application.StartupPath + "\SavedFiles\DC_BACKUP\SavedFiles.zip", Application.StartupPath + "\SavedFiles\")


Guess I'll try and mess around with this for a few more hours and might post back if I need help. Any-who, thanks for the .FileName info!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900