|
-
Aug 10th, 2011, 10:34 AM
#1
Thread Starter
Hyperactive Member
Simple File Transfer
Hello, I've actually been using VB since VB3, but I've never gotten beyond 'novice' level. I just find it a useful tool for getting things done.
(currently using VB.NET 2010 Express)
That said, I'm trying to make a program which will be useful for many people, and there are a few features that I need that I have absolutely no idea where to start. The main of which is file transfer.
I'm trying to create a program that will keep files and folders synchronized across multiple client computers. I'm using a File system watcher to trigger events, and Using a simple System.Net.Sockets UDP client transfer (found via google) to transfer commands between it and itself on other computers.
Here's that code if it helps to know what I have
(this just sends from one textbox to another over the internet)
Code:
Imports System.Net.Sockets
Imports System.Net
Imports System.Text
Dim udpClient As New UdpClient(1024)
Dim RemoteIpEndPoint As New IPEndPoint(IPAddress.Any, 0)
Private Property testvar As Byte()
Private Sub btnwait_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnwait.Click
If BackgroundWorker1.IsBusy Then BackgroundWorker1.CancelAsync()
status.Text = "Listening"
BackgroundWorker1.RunWorkerAsync()
End Sub
Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
Dim receiveBytes As [Byte]() = udpClient.Receive(RemoteIpEndPoint)
testvar = receiveBytes
End Sub
Private Sub BackgroundWorker1_RunWorkerCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BackgroundWorker1.RunWorkerCompleted
boxend.Text = Encoding.ASCII.GetString(testvar)
status.Text = "Ready"
End Sub
Private Sub btnsend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsend.Click
udpClient.Connect(boxip.Text, 1024)
Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(boxmsg.Text)
UdpClient.Send(sendBytes, sendBytes.Length)
End Sub
By this method, I can rename, move, or delete files. I want to implement file transfer, so that whenever a new file is created, or updated, my program will automatically transfer the file to the other computers and update them there.
I would like to not have to purchase any 3rd party components, and the fewest lines of code the better. Please don't just send me to google (I've been searching for a while now) Pretend I've never programmed before when helping. I love comments!
Ok, sure I'm making myself out to be stupid, but I'm really just looking for a good explanation. Thanks in advance for any help offered.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|