Results 1 to 3 of 3

Thread: zip compress remote folders program - problem!

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2009
    Posts
    3

    zip compress remote folders program - problem!

    I am writing a windows forms program using VB express 2008, to copy and zip compress certain folders on remote PCs to a destination backup folder on my PC (the one that the program runs on.) It works great if I do the following FIRST:

    I open windows explorer and navigate to the folder on the remote PC that I want to back up. Then I am prompted for user name and password. I enter my admin username and password. The "connection" to that folder is now established and NOW my program will work--that is, it will successfully zip compress that folder.

    The problem is, if I don't use windows explorer to navigate to the remote folder that I want to back up and enter my user name and password FIRST, that is, before running my program, my program doesn't work--it just creates an empty zip file with nothing in it.

    My question is: how do I programatically 'establish a connection' to a folder on a remote PC? I don't mind if I manually have to enter the User name and password when the program runs. The problem is, my program doesn't even ask, it just fails.

    Thanks, I would greatly appreciate any advice!

  2. #2

    Thread Starter
    New Member
    Join Date
    Dec 2009
    Posts
    3

    Re: zip compress remote folders program - problem!

    I have solved my own problem. I can post the code showing how I did it tomorrow, if anyone is curious.

  3. #3

    Thread Starter
    New Member
    Join Date
    Dec 2009
    Posts
    3

    Re: zip compress remote folders program - problem!

    Here it is:

    establish_connection(fullsource)



    Private Sub establish_connection(ByVal mydir)

    'This procedure allows user to browse a network pc. Username and passsword may need to be entered.

    Dim myStream As Stream = Nothing
    Dim openFileDialog1 As New OpenFileDialog()
    openFileDialog1.InitialDirectory = mydir
    openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
    openFileDialog1.FilterIndex = 2
    openFileDialog1.RestoreDirectory = True
    If openFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
    Try
    myStream = openFileDialog1.OpenFile()
    If (myStream IsNot Nothing) Then
    ' Insert code to read the stream here.
    End If
    Catch Ex As Exception
    MessageBox.Show("Cannot read file from disk. Original error: " & Ex.Message)
    Finally
    ' Check this again, since we need to make sure we didn't throw an exception on open.
    If (myStream IsNot Nothing) Then
    myStream.Close()
    End If
    End Try
    End If
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width