familia Posted September 10, 2003 Posted September 10, 2003 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) Quote
*Experts* mutant Posted September 10, 2003 *Experts* Posted September 10, 2003 Are those files being in use? Quote
familia Posted September 11, 2003 Author Posted September 11, 2003 To: Mutant No, those files are not in use. What I do is selected with mouse-click to delete. Quote
Leaders dynamic_sysop Posted September 12, 2003 Leaders Posted September 12, 2003 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 Quote
familia Posted September 17, 2003 Author Posted September 17, 2003 To: dynamic_sysop Thank you, but I still get an exception (file is busy) Quote
Mehyar Posted September 19, 2003 Posted September 19, 2003 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, Quote Dream as if you'll live forever, live as if you'll die today
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.