On Dec 13, 2006, at 5:50 PM, Norman Palardy wrote:


On Dec 13, 2006, at 3:33 PM, Ed Harris wrote:

As part of the solution for the CreateTextFile problem I posted a couple of days ago, I need an easy way to get a list of files in a folder that match a template, e.g., "temp????.html" where the ? is any single character. It
needs to work on both Mac OS X and Windows.

There isn't

What is the easiest way to do this? I can't figure it out from the RB
documentation.

try and create a file and if it already exists move on to another "unique" name

something like

  dim counter as integer
  dim f as folderItem

  counter = 0

  do
    if counter < 1 then
      f = TemporaryFolder.Child("temp.html")
    else
f = TemporaryFolder.Child("temp" + format(counter,"#") + ".html")
    end if

    counter = counter + 1

  loop until f.Exists = false


Actually, it's even faster to do something like

if TemporaryFolder <> nil then
return TemporaryFolder.Child("temp" + Format(10000000000*Rnd, "#") + ".html"
else
  return nil
end if

Assuming TemporaryFolder <> nil, a few iterations can push the probability of failure below that of a hardware error.

Charles Yeomans
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to