Deleting part of directory content

I want to create v.b 6 exe which doesn't requires any dll.
The program will check if inside the directory there some essentials files are exist if some of these files are missing the directort will be delete except one directory needed in this directory.
I want my program to be efficiency and if it is possible not to move the needed directory (the subdirectory)
to other "temp" directory and the copying the directory after "cleaning" the parent directory.
I had noticed that there is a collection name folders.
Is it possible to use with the command "for each ..."
and then delete each file/directory individualy?
Can you tell me If there are other ways and how do I use them.

Thank you for your time.


grenutzeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

XpGauthamCommented:

Try Using DIR Function

if dir("Path",vbdirectory") <> "" then
  if dir(""path\file") <> "" then
    filesystem.kill(path\file)  
  end if
end if

u can Copy a file from one folder to another by Using FileCopy Function
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
grenutzeAuthor Commented:
Thanks for the advise.
The dir function is very useful, i had use this function and added a loop which passes on all the folders by using the command - dir() inside the loop, and inside the loop i had deleteded all folders except of the wanted directory.
0
grenutzeAuthor Commented:
Here is my code :
-----------------

MyName = Dir(MyPath, vbDirectory)   ' Retrieve the first entry
Do While MyName <> ""   ' Start the loop.
' Use bitwise comparison to make sure MyName is a directory
   If ((GetAttr(MyPath & MyName) And vbDirectory)          = vbDirectory) And (Asc(MyName) <> 46) Then
         ' Display entry only if it's a directory.
      If (MyName <> "xxx") Then
        Set Obj_folder = Obj_fso.GetFolder(MyPath & MyName)
        Obj_folder.Delete True 'deleting the directory
      End If
   End If
   MyName = Dir()   ' Get next entry.
Loop
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.