Free Download Sample VB.Net Apps and its Data Source Code
Sunday, November 13, 2016
MOVE FILES : VB.NET
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
If File.Exists(toloc) Then
File.Delete(toloc)
End If
' Move the file.
File.Move(fromloc, toloc)
Console.WriteLine("{0} moved to {1}", fromloc, toloc)
' See if the original file exists now.
If File.Exists(fromloc) Then
Console.WriteLine("The original file still exists, which is unexpected.")
Else
Console.WriteLine("The original file no longer exists, which is expected.")
End If
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
End Class
Thursday, November 10, 2016
SEARCH FILES ; VB.NET
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
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(txtfilename.Text & txtfextension.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
End Class
Subscribe to:
Posts (Atom)