Hey guys!

I'm going to start a new project, that will make a simple backup of some hard-to-find files.

It'll compress it to a single file (output format will be selectable), but I want it to use a user-defined output dir.

Can someone explain me a bit of how to do it? Place a textbox with the '...' button to select directory and then use it as a variable?

Thanks!

Firstly, I believe that it is customary to post the code you have so far, however if you are compressing the files into one file, it would be quicker to ask for the filename as well. I've put a function below that could be called to get a dialog input from the user, however you will need to put error handling round it to check for an empty response case the user selects cancel.

Public Function UserInput_GetSaveFileName() As String
        Dim CDLG_SaveFile As New SaveFileDialog
        CDLG_SaveFile.CheckPathExists = True
        CDLG_SaveFile.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.MyDocuments
        Dim CDLG_Result As DialogResult = CDLG_SaveFile.ShowDialog
        Select Case CDLG_Result
            Case Windows.Forms.DialogResult.Cancel
                'User pressed cancel - do nothing
            Case Windows.Forms.DialogResult.OK
                'User pressed OK, return filename
                Return CDLG_SaveFile.FileName
            Case Else
                'User has selected another option other than OK or CANCEL, do nothing
        End Select
    End Function

I have no code right now :P
I was planning to use 7zip standalone exe (7za.exe) as compressor, since I'll compress one directory that has a fixed location.

The directory selection would be used as an argument to 7za.exe, telling where it will compress the files.

Other thing... how can I embed a file into my apps main exe? Like... embed 7za.exe into the code and when app run, extract it to temp dir, use it and delete it. :P

Solved. =)

Private Sub Procurar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Procurar.Click
        Dim Salvar As New SaveFileDialog()

        Salvar.InitialDirectory = "c:\"
        Salvar.Filter = "Arquivos zip (*.zip)|*.zip|Arquivos rar (*.rar)|*.rar|Arquivos 7zip (*.7z)|*.7z"
        Salvar.FilterIndex = 2
        Salvar.RestoreDirectory = True

        If Salvar.ShowDialog() = DialogResult.OK Then
            NomedoBackup = Salvar.FileName
            Caminho.Text = NomedoBackup
        End If
    End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.