4 Replies - 432 Views - Last Post: 12 August 2011 - 07:57 PM Rate Topic: ***** 1 Votes

#1 NY Andrew  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 79
  • Joined: 25-May 11

How can I select a .ZIP folder with FolderBrowser OR OpenFile DIALOGS?

Posted 12 August 2011 - 07:20 PM

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:
    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! :)

Is This A Good Question/Topic? 0
  • +

Replies To: How can I select a .ZIP folder with FolderBrowser OR OpenFile DIALOGS?

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 8898
  • View blog
  • Posts: 33,369
  • Joined: 12-June 08

Re: How can I select a .ZIP folder with FolderBrowser OR OpenFile DIALOGS?

Posted 12 August 2011 - 07:36 PM

First up - a zip is a file not a folder. Granted Windows has done a great job integrating zips to appear like folders - at their core they are not.

Second, check the properties of the open file dialog. You'll see a great little one called "filename".

Quote

The file name includes both the file path and the extension

http://msdn.microsof...filedialog.aspx
Was This Post Helpful? 1
  • +
  • -

#3 NY Andrew  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 79
  • Joined: 25-May 11

Re: How can I select a .ZIP folder with FolderBrowser OR OpenFile DIALOGS?

Posted 12 August 2011 - 07:43 PM

View Postmodi123_1, on 12 August 2011 - 07:36 PM, said:

First up - a zip is a file not a folder. Granted Windows has done a great job integrating zips to appear like folders - at their core they are not.

Second, check the properties of the open file dialog. You'll see a great little one called "filename".

Quote

The file name includes both the file path and the extension

http://msdn.microsof...filedialog.aspx

Haha I KNEW someone would point that out. I was going to say that above, but I figured no one would point that out. :whistling:

Anyway, I am not sure how that can relate to my question though. I am trying to get the path of the ZIP. As I mentioned above using FolderBrowserDialog I could use ".SelectedPath" to get the path a file, but with the OpenFileDialog I am unable to get the path of the ZIP.
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 8898
  • View blog
  • Posts: 33,369
  • Joined: 12-June 08

Re: How can I select a .ZIP folder with FolderBrowser OR OpenFile DIALOGS?

Posted 12 August 2011 - 07:46 PM

You can select the zip in the OFD, right? Reread my post and you'll find where to get the file path from the OFD once a file is selected and the OFD closes.
Was This Post Helpful? 1
  • +
  • -

#5 NY Andrew  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 79
  • Joined: 25-May 11

Re: How can I select a .ZIP folder with FolderBrowser OR OpenFile DIALOGS?

Posted 12 August 2011 - 07:57 PM

View Postmodi123_1, on 12 August 2011 - 07:46 PM, said:

You can select the zip in the OFD, right? Reread my post and you'll find where to get the file path from the OFD once a file is selected and the OFD closes.

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! :sigh:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1