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:
If My.Computer.Network.Ping("ftp://00.000.000.000/", 1000) Then MsgBox("Server pinged successfully.") Else MsgBox("Ping request timed out.") End If For Each CurrentFile As String In IO.Directory.GetFiles("C:\kircheck\") My.Computer.Network.UploadFile(CurrentFile, "ftp://00.000.000.000/" & "folder\folder" + New IO.FileInfo(CurrentFile).Name, "usernmae", "Password", True, 500, FileIO.UICancelOption.ThrowException) MessageBox.Show(CurrentFile) Next End Sub Private Sub Backup_Click(sender As System.Object, e As System.EventArgs) Handles Backup.Click Dim sourcepath As String = "C:\check\*.*" Dim DestPath As String = "C:\processed" CopyDirectory(sourcepath, DestPath) End Sub Private Shared Sub CopyDirectory(ByVal sourcePath As String, ByVal destPath As String) If Not Directory.Exists(destPath) Then Directory.CreateDirectory(destPath) End If For Each file__1 As String In Directory.GetFiles(Path.GetDirectoryName(sourcePath)) Dim dest As String = Path.Combine(destPath, Path.GetFileName(file__1)) File.Copy(file__1, dest) Next For Each folder As String In Directory.GetDirectories(Path.GetDirectoryName(sourcePath)) Dim dest As String = Path.Combine(destPath, Path.GetFileName(folder)) CopyDirectory(folder, dest)




Reply With Quote