Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Beginning VB 6
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 26th, 2005, 01:52 PM
Registered User
 
Join Date: Oct 2005
Location: Green Island, New York, USA.
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
objFSO.DeleteFile
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?

Thanks
-John-

John
Reply With Quote
  #2 (permalink)  
Old October 27th, 2005, 02:10 AM
Friend of Wrox
 
Join Date: Nov 2003
Location: Johannesburg, , South Africa.
Posts: 141
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to acdsky
Default

Hi

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.

Regards
Marnus
Reply With Quote
  #3 (permalink)  
Old October 29th, 2005, 09:45 AM
Registered User
 
Join Date: Oct 2005
Location: Dubai, , United Arab Emirates.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Apocalypse
Default

Thanx Marnus for the great link

<center>http://img223.imageshack.us/img223/3803/image3ja.gif</center>
<center>
http://img442.imageshack.us/img442/6...ypse2gm.th.jpg
http://img53.imageshack.us/img53/781...ruction4ef.gif
</center>
<center>http://www.danasoft.com/sig/ApocalypseTheGreat.jpg</center>
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 03:48 PM.


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