Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Beginning VB 6
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old October 26th, 2005, 01:52 PM
Registered User
Join Date: Oct 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Script to delete files after a set number

Hello to all. I am trying to create a script that will delete files in a folder after the file count reaches a specific number, say, 7.

This is what I have written:

Option Explicit
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
DeleteFiles fso.GetFolder("C:\Test")
Sub DeleteFiles(srcFolder)
Dim srcFile
If srcFolder.Files.Count > 7 Then
Exit Sub
End If
End Sub

I know it is wrong as it returns error messages. Could someone help me with this script? Also, could you recommend a good book or website which would helpd me going forward?


Old October 27th, 2005, 02:10 AM
Friend of Wrox
Join Date: Nov 2003
Posts: 141
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to acdsky


Have a look at this article: http://www.aivosto.com/visdev/fso.html

The last bit "The File Object" will answer your question. The rest of the article is also good stuff.

Old October 29th, 2005, 09:45 AM
Registered User
Join Date: Oct 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Apocalypse

Thanx Marnus for the great link


Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete Archive Logs Script rstelma Oracle 1 October 28th, 2004 01:18 PM
Delete X number of records slgknjn Access 1 August 22nd, 2004 08:24 AM
[?]how to set page number when printing? jodgen VB How-To 0 April 14th, 2004 02:30 AM
Delete script doesnt execute kosla78 Classic ASP Basics 1 November 19th, 2003 07:44 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.