Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 172
  • Last Modified:

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.

  • 2
1 Solution

Try Using DIR Function

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

u can Copy a file from one folder to another by Using FileCopy Function
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.
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.

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now