SystemFileWatcher and FTP
If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
1 post
Page 1 of 1
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.
1 post
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023