Results 1 to 5 of 5

Thread: automate upload file to ftp server

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2013
    Posts
    4

    automate upload file to ftp server

    Hi,

    I am very new to VB.Net and my company has told me to develop- an application like whenever the scout drive is attached to network it should ping the ftpserver and upload all files to ftp server and create a new directory in the scout drive and should backup those video files. This is on client side and it should be done everyday when the scout is networked I was able to upload and create new directory and copy the files but struggling with the automate upload everyday I want some help on this.
    I know I an use windows scheduler or timer but my application should be triggered when the scout drive is attached on network. here is my code...
    vb.net Code:
    1. If My.Computer.Network.Ping("ftp://00.000.000.000/", 1000) Then
    2.             MsgBox("Server pinged successfully.")
    3.         Else
    4.             MsgBox("Ping request timed out.")
    5.         End If
    6.  
    7.         For Each CurrentFile As String In IO.Directory.GetFiles("C:\kircheck\")
    8.             My.Computer.Network.UploadFile(CurrentFile, "ftp://00.000.000.000/" & "folder\folder" + New IO.FileInfo(CurrentFile).Name, "usernmae", "Password", True, 500, FileIO.UICancelOption.ThrowException)
    9.             MessageBox.Show(CurrentFile)
    10.         Next
    11.     End Sub
    12.  
    13.     Private Sub Backup_Click(sender As System.Object, e As System.EventArgs) Handles Backup.Click
    14.  
    15.         Dim sourcepath As String = "C:\check\*.*"
    16.         Dim DestPath As String = "C:\processed"
    17.         CopyDirectory(sourcepath, DestPath)
    18.  
    19.     End Sub
    20.     Private Shared Sub CopyDirectory(ByVal sourcePath As String, ByVal destPath As String)
    21.         If Not Directory.Exists(destPath) Then
    22.             Directory.CreateDirectory(destPath)
    23.         End If
    24.  
    25.         For Each file__1 As String In Directory.GetFiles(Path.GetDirectoryName(sourcePath))
    26.             Dim dest As String = Path.Combine(destPath, Path.GetFileName(file__1))
    27.             File.Copy(file__1, dest)
    28.         Next
    29.  
    30.         For Each folder As String In Directory.GetDirectories(Path.GetDirectoryName(sourcePath))
    31.             Dim dest As String = Path.Combine(destPath, Path.GetFileName(folder))
    32.             CopyDirectory(folder, dest)
    Last edited by Hack; May 2nd, 2013 at 07:52 AM. Reason: Added Highlight Tags and Removed IP Address

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