|
-
Feb 6th, 2003, 04:08 AM
#1
Thread Starter
Fanatic Member
Finding the highest number in a directory... STILL UNRESOLVED
We are currently building a package which places each estimate number into a file like this...
c:\estimates\1.txt
c:\estimates\2.txt
c:\estimates\3.txt
etc.
I have programmed a listview to read-in all the files in the estimates directory... but you have to give it a number from at to... IE.
For Intx = 0 to 25000
The question being... how can i search the directory for the highest number of file to that number can replace the 25000 in the example. The trouble is, when the user enters a number 25001... it won't find it.
I can't set the number to 10000000 before anyone asks....as it would take weeks to open the program.
Any help would be much appeciated.
Regards,
Paul.
Last edited by VisionIT; Feb 6th, 2003 at 04:43 AM.
-
Feb 6th, 2003, 04:14 AM
#2
Frenzied Member
Use DIR() and that will step through all files with the required name.
Use the FSO, and obtain the .Count property.
Save the last number used in the Registry / a file.
Sort the directory and get the last number.
-
Feb 6th, 2003, 04:20 AM
#3
Thread Starter
Fanatic Member
Any idea's on physical code M8... you lost me a bit there! 
Regards,
Paul.
-
Feb 6th, 2003, 04:46 AM
#4
Frenzied Member
There are different approaches that you could use (some of which are shown above). Some are repeated here with more details:
Use DIR() and step through all files with the required name.
VB Code:
SearchName = "C:\Estimates\*.TXT"
f = Dir(SearchName, vbReadOnly)
While f <> ""
MsgBox f
f = Dir()
Wend
Use the FSO, and obtain the .Count property.
VB Code:
Dim FS As New FileSystemObject
Dim FSfile
Dim FSfolder As Folder
Dim subfolder As Folder
Set FSfolder = FS.GetFolder("C:\Estimates")
MsgBox "Files are: " & FSfolder.Files.Count
Set FSfolder = Nothing
End Sub
Save the last number used in the Registry / a file.
<<Look up the GetSettings and SaveSettings commands>>
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
|