-
January 19th, 2012, 12:18 PM
#1
CopyFile in VB.net
Hi
Can anyone help me i am try ing to copy a file from one location to another useing an openfile dialog but it dosn't seem to work any ideas welcome. The code i am using is below
FileCopy(OpenFileDialog1.FileName, "C:\temp\trial.tar")
-
January 19th, 2012, 01:10 PM
#2
Re: CopyFile in VB.net
Hi,
try using the File Class
Code:
Imports System.IO.File
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim FileToCopy As String
Dim NewCopy As String
OpenFileDialog1.ShowDialog()
FileToCopy = OpenFileDialog1.FileName.ToString
'FileToCopy = "c:\temp\test1.txt"
NewCopy = "c:\temp\test2.txt"
If System.IO.File.Exists(FileToCopy) = True Then
System.IO.File.Copy(FileToCopy, NewCopy, True)
MessageBox.Show("File Copied")
Else
MessageBox.Show("File doesn't exist")
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
End Class
Curt
-
January 20th, 2012, 06:04 AM
#3
Re: CopyFile in VB.net
Thanks
I'll give that a go over the weekend and let you know
-
January 20th, 2012, 03:11 PM
#4
Re: CopyFile in VB.net
Ok that seems to work ok
However if i try to copy a file from my external usb drive it comes up with an error of file already in use
Any idea's!
Tags for this Thread
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
|