Victor Charles
asked on
Help with accessing excel file
Hello,
When attempting to access an excel file I receive the following error evnthough it is not being used by another application:
The process cannot access the file 'parh\Debug\DataA.xls' because it is being used by another process.
on line:
IO.File.Copy(TextBox2.Text , destinationPathWithSourceN ame, True)
How do I avoid this error?
When attempting to access an excel file I receive the following error evnthough it is not being used by another application:
The process cannot access the file 'parh\Debug\DataA.xls' because it is being used by another process.
on line:
IO.File.Copy(TextBox2.Text
How do I avoid this error?
If IO.File.Exists(destinationPathWithSourceName) Then
If MessageBox.Show("Destination already exists!" & vbCrLf & vbCrLf & "File: " & destinationPathWithSourceName, "Replace File?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
IO.File.Copy(TextBox2.Text, destinationPathWithSourceName, True)
If File.Exists(destinationPathWithDestName) Then 'Delete Data.xls if it already exists
My.Computer.FileSystem.DeleteFile(destinationPathWithDestName)
End If
My.Computer.FileSystem.RenameFile(destinationPathWithSourceName, "Data.xls")
' namesheet()
makeDataTableFromSheetNameUpload()
loadgrid()
End If
Else
IO.File.Copy(TextBox2.Text, destinationPathWithSourceName)
If File.Exists(destinationPathWithDestName) Then 'Delete Data.xls if it already exists
My.Computer.FileSystem.DeleteFile(destinationPathWithDestName)
End If
My.Computer.FileSystem.RenameFile(destinationPathWithSourceName, "Data.xls")
'namesheet()
makeDataTableFromSheetNameUpload()
loadgrid()
Label3.Visible = True
ComboBox2.Visible = True
End If
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
It's certainly not the code because the error doesn't occur when publish the application. The file doesn't show on the task, must be something going on with my latop.
Thanks,
V.