Writint to textfiles

Results 1 to 6 of 6

Thread: Writint to textfiles

  1. #1
    Rog Guest

    Default Writint to textfiles

    How do i get ASP to write at the beginning of my textfile insted of at the end of it?

  2. #2
    tabsquare Guest

    Default RE: Writint to textfiles

    the common syntax when you open a file is:<BR>Set objFile = objFS.OpenTextFile("filename", mode, createfile)<BR>There are three values you use to open your file, replacing the "mode" parameter with:<BR>1= to read only the file<BR>2= to rewrite the file <BR>8= for appending at the end of the file<BR><BR>In my knowledge there is no way to insert text at the beginning of a file if this is what you mean.<BR> <BR><BR><BR>

  3. #3
    Join Date
    Dec 1969

    Default Correct answer...*AND*...

    This is true for all text files on all computers on all operating systems. Period. It is *not* a limitation of ASP or VBScript or any MS technology.<BR><BR>If you need to order things, use a database. That is *NOT* what text files are for.<BR><BR>

  4. #4
    Join Date
    Dec 1969

    Default RE: Writint to textfiles

    Well, it can be done of course<BR><BR>First open the file for reading, and set a variable to hold the contents of the file.<BR><BR>Now, close the file, and open it again, this time For Writing. this deletes the text file and starts writing at the beginning.<BR><BR>So do a fileObject.Write "This is new first line" & vbcrlf & strStringHoldingRestOfFile<BR><BR>(vbcrlf is, of course, a line break)<BR><BR>hope that helps..

  5. #5
    tabsquare Guest

    Default RE: Writint to textfiles

    AH HA HA, I have found a place where inserting text at the beginning of a file is possible. Try out Tera-Byte.com<BR>It&#039;s all day I&#039;m trying to let a stupid script when I realised that the FileSystemObject on the server wasn&#039;t working.<BR>if I open a file like that<BR>set objFile = objFSO.OpenTextFile(name, 2, true)<BR>the file will not be rewrited, but the text you insert every new time, will be appended at the beginning of the file.<BR>Hope I really can solve that

  6. #6
    Richard A. Lowe Guest

    Default Strictly speaking....

    ... you can&#039;t APPEND to the start of a file. You, of course, can re-write the entire file with new data at the beginning. I believe that&#039;s what Bill is talking about.<BR><BR>R.

Posting Permissions

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