BUG: FileCopy Does Not Reset Err if Floppy is Write- Protected (159975)
The information in this article applies to:
- Microsoft Visual Basic Standard Edition for Windows 4.0
- Microsoft Visual Basic Professional Edition for Windows 4.0
- Microsoft Visual Basic Enterprise Edition for Windows 4.0
This article was previously published under Q159975 SYMPTOMS
The Err object is not reset after you try to copy a file to a write-
protected floppy disk and the FileCopy command fails with a "Permission
Denied" error. This makes it impossible to copy the file again, even after
you remove the write-protection on the floppy disk.
WORKAROUND
The Kill command is not affected in this way and can be carried out before
the FileCopy command. This enables the Kill command to detect the
"Permission Denied" error first and allows you to remove the write-
protection on the floppy disk before you carry out the FileCopy command. Do
the following:
Private Sub Command1_Click()
Dim source As String
Dim target As String
On Error GoTo err_handler
source = "c:\test.txt"
Open source For Output As #1
Write #1, "This is a test."
Close #1
target = "a:\test.txt"
If Dir(target) <> "" Then Kill target
FileCopy source, target
Exit Sub
err_handler:
If Err.Number = 70 Then
MsgBox "Permission denied. Please remove write-protection."
Resume
ElseIf Err.Number = 71 Then
MsgBox "Disk not ready. Please insert a disk."
Resume
End If
End Sub
STATUS
Microsoft has confirmed this to be an issue in the Microsoft products
listed at the beginning of this article. Microsoft is researching this
issue and will post new information here in the Microsoft Knowledge Base as
it becomes available.
Modification Type: | Minor | Last Reviewed: | 7/16/2004 |
---|
Keywords: | kbbug KB159975 |
---|
|