By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,916 Members | 1,305 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,916 IT Pros & Developers. It's quick & easy.

deleting a directory

P: 9
Hi

I am moving list of files from one directory to another directory.i am doing it by first moving all the files from the source directory to destination directory using filecopy command.then using rmdir command to remove the source directory..
the problem which i am facing is..
For example, i have two files in the directory named A and the size of the total dir is some 6.00kb. after deleting the files in the directory A i thought the directory size also becomes empty.but its showing 6.00kb eventhough no files are there in the deirectory.so i am getting an error
"file/path access error " while removing the directory using rmdir.

Anyone plz tell me how can i resolve this problem
Thanks in advance
Kalai
Dec 11 '06 #1
Share this Question
Share on Google+
4 Replies


Expert 5K+
P: 8,434
Any chance you could post the existing code here, so we can see exactly what you've done so far? (Just the parts relevant to moving the files, that is).

(Also, I wonder whether Windows Indexing Service might be trying to update things and getting in the way.)
Dec 11 '06 #2

P: 9
the necessary code is below...plz help me to delete the files and directory permanently.

Private Sub cmdDVD_Click()

dname = Dir1.Path
chcount = InStrRev(dname, "\")
dirname = Mid(dname, chcount + 1, Len(dname))
dpath = "c:\dvd\" & dirname
If Dir(dpath, vbDirectory) = vbNullString Then
MkDir dpath
End If

For fcount = 0 To File1.ListCount - 1
DirPath = Dir1.Path & "\" & File1.List(fcount)
dest = dpath & "\" & File1.List(fcount)
FileCopy DirPath, dest
'Kill DirPath
delete DirPath
Next fcount

RmDir Dir1.Path
MsgBox "archived in " & dpath


End Sub
thanks
Kalai
Dec 12 '06 #3

Expert 5K+
P: 8,434
Is it possible that there are hidden files in the directory?

Another thing which comes to mind is that Windows XP often refuses to let you delete a directory because some program has it open. In this case, it might be your own program. Try changing the current directory, or the Path of your dir/file listboxes before doing the RmDir, so that nothing is referencing that directory.

As an example of what I mean, I've had cases where I opened a DOS window to go and delete some files (or view then, or whatever). Then in Explorer, I deleted everything in the folder, and tried to delete it. Windows wouldn't let me, because it was in use. I had to close the DOS window, or change its current directory, before I could do it.

P.S. Where are you seeing the 6 KB size after deleting the files? Maybe you just need to refresh something.
Dec 12 '06 #4

P: 9
what u hve mentioned is correct.i changed the path of the dirlist before deleting.it works fine.
thank you very much.
Kalai

Is it possible that there are hidden files in the directory?

Another thing which comes to mind is that Windows XP often refuses to let you delete a directory because some program has it open. In this case, it might be your own program. Try changing the current directory, or the Path of your dir/file listboxes before doing the RmDir, so that nothing is referencing that directory.

As an example of what I mean, I've had cases where I opened a DOS window to go and delete some files (or view then, or whatever). Then in Explorer, I deleted everything in the folder, and tried to delete it. Windows wouldn't let me, because it was in use. I had to close the DOS window, or change its current directory, before I could do it.

P.S. Where are you seeing the 6 KB size after deleting the files? Maybe you just need to refresh something.
Dec 14 '06 #5

Post your reply

Sign in to post your reply or Sign up for a free account.