Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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)

  • Leaders
Posted

could you not do something like this...

   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 isn't running, just delete the file.
           End If
       Next
   End Sub

Posted

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,

Dream as if you'll live forever, live as if you'll die today

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...