Home
Manage Your Code
Snippet: File creation and deletion (VB.NET)
Title: File creation and deletion Language: VB.NET
Description: Finding a file deleting and re-adding it Views: 61
Author: Tom Baggett Date Added: 1/26/2012
Copy Code  
1 Public Sub CreateRunDatasheet()
2        Dim fileSource As String = "\\srvfile1\PipelineUsers\Databases\Pipeline\"
3        Dim fileDestination As String = "C:\Program Files\Victory Packaging\Pipeline"
4        Dim fileName As String = "RunDatasheet.exe"
5        Dim fMsg As New WaitingForm
6        Dim deleteFile As String = "C:\Program Files\Victory Packaging\Pipeline\RunDatasheet.exe"
7        'create a new object for the message form
8        fMsg.TopMost = True                'this is to make sure that the message form is displayed at the top of your windows and the users cannot do anything to it except waiting
9        fMsg.Show()
10
11        If File.Exists(deleteFile) Then
12            File.Delete(deleteFile)
13        End If
14
15        My.Computer.FileSystem.CopyFile(fileSource & "\" & fileName, fileDestination & "\" & fileName)
16
17        fMsg.Close()
18    End Sub