I have an application that primarily moves files from one location to another. I need to get the user's response when asked by Windows if they would like to overwrite or rename the new file because it already exists in the destination selected on the form. I basically need to receive a boolean value so i can update the transaction logs. The function follows:
All help is greatly appreciated. Thanks.Code:This function handles copying files from one location to the destination specified on the form Public Function copyToNewLoc(ByVal source As String, ByVal destination As String, ByVal bln As Boolean) As Boolean Try ' Copies files, and shows the probress bar during the file move My.Computer.FileSystem.CopyFile(source, destination, FileIO.UIOption.AllDialogs) bln = FileIO.UIOption.AllDialogs Catch ex1 As NullReferenceException MessageBox.Show("A null reference error occured. Please enter both source and destination paths to the file(s).") bln = False Catch ex7 As ArgumentOutOfRangeException MessageBox.Show("An error occured: " & ex7.ToString) bln = False Catch ex2 As AccessViolationException MessageBox.Show("The application experienced an access violation error when attempting to copy the file.") bln = False Catch ex3 As DirectoryNotFoundException MessageBox.Show("The directory was not found.") bln = False Catch ex4 As FileNotFoundException MessageBox.Show("The file was not found.") bln = False Catch ex5 As IOException MessageBox.Show("An error occured when attempting to copy: " & ex5.ToString) bln = False Catch ex6 As Exception MessageBox.Show("An error occured: " & ex6.ToString) bln = False End Try Return bln End Function




Reply With Quote
