I want to make a program that can read and delete text file in drive C: I am able to read already but deleting is my problem. I want to auto delete the text file after entering the correct username and password.
Here is my code. When i click confirm button after entering pass and username.
I tried the code below but it said an error.
The process cannot access the file ..("C:\Users\smt32\Documents\CP1 FILES\buzzer\test.txt"). because it is being used by another process
Private Sub btnConfirm_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConfirm.Click
    Dim user, pass As String
    user = (txtUserName.Text)
    pass = (txtPass.Text)
    If user = "test" And pass = "test" Then
        Me.Close()
        'Kill("C:\Users\smt32\Documents\CP1 FILES\buzzer\test.txt")
        ' My.Computer.FileSystem.DeleteFile("C:\Users\smt32\Documents\CP1 FILES\buzzer\test.txt")
        System.IO.File.Delete("C:\Users\smt32\Documents\CP1 FILES\buzzer\test.txt")
    Else
        MsgBox("wrong pass")
    End If
End Sub
 
     
    