Random numbers as file names

Results 1 to 3 of 3

Thread: Random numbers as file names

  1. #1
    Freq Flyer Guest

    Default Random numbers as file names

    I tried this a bit but couldn&#039;t get it to work and I am sure it is a formatting issue. I am soliciting values from a form, concatenating date/time stamp information and some cookies to a variable and then using the ASP write text feature to write that variable out to the web server as a text file. However, since this activity will occur about 8,000 times a day AND most often quite simultaneously, I am hesitant to use the append function and would rather use the create new file function. To make each file unique, I am generating a random number and letting that number (assigned to a variable name) become the file name. I copy all the files into one file in an unattended process later. Can you help me with the format to use a variable name for the file name instead of something like "c:asp24h.txt" ?<BR><BR>Thank you very much!<BR><BR>Chad

  2. #2
    Join Date
    Dec 1969

    Default RE: Random numbers as file names

    I&#039;m not sure what you&#039;re asking. But here goes...<BR><BR>You can use a variable in call to CreateTextFile().<BR><BR>object.CreateTextFile(fil ename[, overwrite[, unicode]])<BR>filename<BR>Required. String expression that identifies the file to create.<BR><BR>e.g.<BR><BR>strFileName = "C:someDirectory\" & intRandNum & ".txt"<BR>set oTx = oFS.CreateTextFile(strFileName, TRUE)<BR><BR>You&#039;d have to make sure the "someDirectory" exists, or you&#039;re perpared to create it in your programming.<BR><BR>-<BR><BR>If you&#039;re asking about the format of this filename, that depends. If you want to seperate them by day you may use: date_randomNumber.txt. (date would be in yyyymmdd format, i.e. <BR>Jan 18, 2001 = 20010118)<BR><BR>Or you may create directories for each day, use that to seperate the files and name the files with some prefix: somePrefix_randNumber.txt. <BR><BR>Personally, I&#039;d hate to ever look at listing of "20010118_12313423452353.txt" so, I&#039;d use a prefix.<BR><BR>Does that answer your question?

  3. #3
    Join Date
    Dec 1969

    Default RE: Random numbers as file names

    Does it answer my question? Absolutely. Fortunately I will never have to look at the file name as on a predetermined unattended schedule, a simple utility will copy all of these files into one file which will then be imported into a database for analysis.<BR><BR>Your help is greatly appreciated.<BR><BR>Do you have an American Airlines AAdvantage number?<BR><BR>Chad <BR>Business Applications Development<BR>AAdvantage Customer Service<BR>chad.hullender@aa.com<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts