SystemFileWatcher and FTP
Posted: Wed Feb 22, 2012 10:33 pm
Alright. I have my application watching my desktop, pictures, music, and document folders. I have seen examples of ftp similar to this:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim request As System.Net.FtpWebRequest = DirectCast(System.Net.WebRequest.Create("ftp://ftp.drivehq.com/file.txt"), System.Net.FtpWebRequest)
request.Credentials = New System.Net.NetworkCredential("user", "password")
request.Method = System.Net.WebRequestMethods.Ftp.UploadFile
Dim file() As Byte = System.IO.File.ReadAllBytes("c:\file.txt")
Dim strz As System.IO.Stream = request.GetRequestStream()
strz.Write(file, 0, file.Length)
strz.Close()
strz.Dispose()
End Sub
so for instance. this is the handler:
AddHandler watchfolder.Renamed, AddressOf logrename
What would I need to put into sub logrename() in order for it to automatically upload the renamed file onto my server. This will also be for changed and created files.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim request As System.Net.FtpWebRequest = DirectCast(System.Net.WebRequest.Create("ftp://ftp.drivehq.com/file.txt"), System.Net.FtpWebRequest)
request.Credentials = New System.Net.NetworkCredential("user", "password")
request.Method = System.Net.WebRequestMethods.Ftp.UploadFile
Dim file() As Byte = System.IO.File.ReadAllBytes("c:\file.txt")
Dim strz As System.IO.Stream = request.GetRequestStream()
strz.Write(file, 0, file.Length)
strz.Close()
strz.Dispose()
End Sub
so for instance. this is the handler:
AddHandler watchfolder.Renamed, AddressOf logrename
What would I need to put into sub logrename() in order for it to automatically upload the renamed file onto my server. This will also be for changed and created files.