Hi
I am having trouble ejecting the USB device. It gives an error saying " The device cannot be stopped right now. Try stopping the device later"
To duplicate the problem, I created a very simple application with two forms.
Form 1 has a button to the Form 2.
Public Class Form1
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim f As New Form2
Try
f.ShowDialog()
Finally
f.Dispose()
f = Nothing
End Try
End Sub
End Class
Form 2 has a button to the OpenFileDialog, in which we select a file and click open, and close the Form2. Now I am on Form 1 and I want to eject the USB drive. But I am unable to do that.
Public Class Form2
Dim openfiledialog1 As OpenFileDialog
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
OpenFileDialog1.ShowDialog()
End Sub
Private Sub Form2_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
openfiledialog1.Dispose()
openfiledialog1 = Nothing
End Sub
Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
openfiledialog1 = New OpenFileDialog
End Sub
End Class
To me, it seems that the OpenFileDialog or form is holding a lock to one of the folders. All I want to do is, eject the USB drive using "safely remove hardware" without getting the busy message, while I am on Form2. Could anyone help me with this.
Thanks
I am having trouble ejecting the USB device. It gives an error saying " The device cannot be stopped right now. Try stopping the device later"
To duplicate the problem, I created a very simple application with two forms.
Form 1 has a button to the Form 2.
Public Class Form1
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim f As New Form2
Try
f.ShowDialog()
Finally
f.Dispose()
f = Nothing
End Try
End Sub
End Class
Form 2 has a button to the OpenFileDialog, in which we select a file and click open, and close the Form2. Now I am on Form 1 and I want to eject the USB drive. But I am unable to do that.
Public Class Form2
Dim openfiledialog1 As OpenFileDialog
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
OpenFileDialog1.ShowDialog()
End Sub
Private Sub Form2_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
openfiledialog1.Dispose()
openfiledialog1 = Nothing
End Sub
Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
openfiledialog1 = New OpenFileDialog
End Sub
End Class
To me, it seems that the OpenFileDialog or form is holding a lock to one of the folders. All I want to do is, eject the USB drive using "safely remove hardware" without getting the busy message, while I am on Form2. Could anyone help me with this.
Thanks