Delete files

familia

Member
Joined
Jul 21, 2003
Messages
8
Location
Panama, Rep. de Panama
I have a Folder with some image files. After I delete the first file and try to delete another one, I get an exception ( The file is busy). Can someone Help me ?

This is the code I am using: System.IO.File.Delete(path)
 
could you not do something like this...
Code:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim procs As Process

        For Each procs In Process.GetProcesses(Environment.MachineName)
            If procs.ProcessName = "the file name" Then /// for example notepad.
                procs.CloseMainWindow()
                IO.File.Delete("D:\the file path") /// delete the .txt file which was open in the running process of notepad.
            Else
                IO.File.Delete("D:\the file path") /// if the process isnt running, just delete the file.
            End If
        Next
    End Sub
 
familia, open your task manager, check if the there is a process aspnet_wp.exe and end that process.

If this also doesnot work then may be you are trying to delete the files and the visual studio .net (the project that is using them is open). Close Visual studio .net and then delete the files.

Hope this helps,
 
Back
Top