VB.Net App that let you search and copy files from remote location to another :
DOWNLOAD SOURCE CODE: SEARCH AND COPY
Imports System
Imports System.IO
Imports System.Text
Public Class Form1
Public Sub trans()
Dim fromloc As String = txtfrom.Text & "\" & txtfilename.Text
Dim toloc As String = txtto.Text & "\" & txtfilename.Text
Try
If File.Exists(fromloc) = False Then
Dim fs As FileStream = File.Create(fromloc)
fs.Close()
End If
File.Copy(fromloc, toloc)
Console.WriteLine("{0} moved to {1}", fromloc, toloc)
MessageBox.Show("File Copied . . . ")
Catch ex As Exception
MessageBox.Show(ex.Message, "transfer")
End Try
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
trans()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
ListBox1.Items.Clear()
sear(txtfilename.Text)
End Sub
Private Sub sear(ByVal item)
Try
Dim Folder As New IO.DirectoryInfo(txtlocation.Text)
For Each File As IO.FileInfo In Folder.GetFiles("*" & txtfsearch.Text & "*", IO.SearchOption.AllDirectories)
ListBox1.Items.Add(File.FullName)
Application.DoEvents()
Next
Catch ex As Exception
MessageBox.Show(ex.Message, "search")
End Try
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim ini() As String
Dim count As Integer = 0
Using sr As New System.IO.StreamReader(".\settings.ini")
Dim Line As String = sr.ReadToEnd
ini = Line.Split(vbCrLf)
While ini.Length <> count
ini(count) = ini(count).Replace(vbCr, "").Replace(vbLf, "")
count = count + 1
End While
End Using
txtlocation.Text = ini(0)
txtto.Text = ini(1)
End Sub
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
Dim leng As Integer
Dim scn As String = ""
Try
leng = Len(ListBox1.SelectedItem)
While scn <> "\" And leng <> 0
scn = Mid(ListBox1.SelectedItem, leng, 1)
If scn <> "\" And leng <> 0 Then
leng = leng - 1
Else
leng = leng + 1
End If
End While
txtfilename.Text = Mid(ListBox1.SelectedItem, leng, Len(ListBox1.SelectedItem) - leng + 1)
txtfrom.Text = Mid(ListBox1.SelectedItem, 1, leng - 2)
Catch ex As Exception
MessageBox.Show(ex.Message, "listbox")
End Try
End Sub
End Class
No comments:
Post a Comment