|
-
Apr 28th, 2000, 08:27 PM
#1
Thread Starter
New Member
DIR & file functions
How can I check a directory to see whether it exists?
If exists, how can I delete all files & sub folders under that directory?.
Please help!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
Apr 28th, 2000, 08:55 PM
#2
transcendental analytic
dir command will tell you if it exists or not. I don't know any direct way of deleting every file an subdir in that dir but you could always go trough every single subdir having a procedure call itself to search trough subdirs and delete all file and remove the subdir. I have some related code if you want
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Apr 29th, 2000, 12:01 AM
#3
Addicted Member
Just a little DOS command, instead of using a recursive function to delete everything under a directory in VB (which works, but is way too much work), use the shell command with Deltree, as follows:
Code:
Call Shell("DELTREE /Y " & sDirectory, vbHide)
It just sooo much easier! WHY doesn't VB or API include this command???
BTW, make sure that the path that you specify does NOT include a trailing backslash, if it does then it will only delete everything under the specified directory and not the directory itself, for example:
wrong: sDirectory = "C:\TEMP\TEST\"
right: sDirectory = "C:\TEMP\TEST"
Dan PM
Analyst Programmer
VB6 SP3 (also VB4 16-bit sometimes  )
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|