File System Object question

Discussion in 'ASP General' started by PedroX, Jun 27, 2005.

  1. PedroX

    PedroX Guest

    I have about 200 documents to which I need to write a header and a footer.
    Appending (the footer) is easy, but I cannot figure out how to write to the
    very beginning of the file. Any help would be appreciated
    PedroX, Jun 27, 2005
    #1
    1. Advertising

  2. PedroX

    Curt_C [MVP] Guest

    PedroX wrote:
    > I have about 200 documents to which I need to write a header and a footer.
    > Appending (the footer) is easy, but I cannot figure out how to write to the
    > very beginning of the file. Any help would be appreciated
    >
    >


    put your new text into a string1,
    read in the contents of the doc to string2
    string1 = string1 + string2
    save string1 back to the doc.

    --
    Curt Christianson
    site: http://www.darkfalz.com
    blog: http://blog.darkfalz.com
    Curt_C [MVP], Jun 27, 2005
    #2
    1. Advertising

  3. PedroX

    McKirahan Guest

    "PedroX" <> wrote in message
    news:RXXve.1106$...
    > I have about 200 documents to which I need to write a header and a footer.
    > Appending (the footer) is easy, but I cannot figure out how to write to

    the
    > very beginning of the file. Any help would be appreciated


    Your "documents", I gather, are text files and not MS-Word documents.

    You'll have to "rewrite" to entire text file.

    Use the ReadAll method to read the intial file then write your header,
    the initial file, and the footer to the same file.
    McKirahan, Jun 27, 2005
    #3
  4. PedroX

    PedroX Guest


    > Use the ReadAll method to read the intial file then write your header,
    > the initial file, and the footer to the same file.


    Thanks 4 the replies. I guess that should work. The documents are XML files.
    They are about 10 mb each. Would that be a problem?
    PedroX, Jun 27, 2005
    #4
  5. PedroX

    Ken Jenkins Guest

    well, thats not the greatest situation to have going on.. those are big
    files


    "PedroX" <> wrote in message
    news:VuYve.1129$...
    >
    >> Use the ReadAll method to read the intial file then write your header,
    >> the initial file, and the footer to the same file.

    >
    > Thanks 4 the replies. I guess that should work. The documents are XML
    > files.
    > They are about 10 mb each. Would that be a problem?
    >
    >
    >
    >
    Ken Jenkins, Jun 27, 2005
    #5
  6. PedroX wrote:
    >> Use the ReadAll method to read the intial file then write your
    >> header, the initial file, and the footer to the same file.

    >
    > Thanks 4 the replies. I guess that should work. The documents are XML
    > files. They are about 10 mb each. Would that be a problem?


    Please don't crosspost to so many groups. This question had nothing to do
    with databases (db) or components, so it was certainly off-topic in those
    groups, which I've removed from this reply.

    If you had mentioned from the start that you were using XML files, you would
    have received a different answer. FileSystemObject is not necessary for
    modifying XML . I suggest you provide a small example of what you want to
    do. Are you really adding information outside of the XML? Or are you adding
    nodes to the XML?

    Bob Barrows

    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
    Bob Barrows [MVP], Jun 27, 2005
    #6
  7. PedroX

    Roland Hall Guest

    "McKirahan" wrote in message news:...
    : "PedroX" <> wrote in message
    : news:RXXve.1106$...
    : > I have about 200 documents to which I need to write a header and a
    footer.
    : > Appending (the footer) is easy, but I cannot figure out how to write to
    : the
    : > very beginning of the file. Any help would be appreciated
    :
    : Your "documents", I gather, are text files and not MS-Word documents.
    :
    : You'll have to "rewrite" to entire text file.
    :
    : Use the ReadAll method to read the intial file then write your header,
    : the initial file, and the footer to the same file.

    If you were going to do that, wouldn't this be easier?

    sub appendit(file1, file2, file3, t)
    dim fso, temp, tempFile, wshShell, oExec
    set fso = CreateObject("Scripting.FileSystemObject")
    set wshShell = CreateObject("WScript.Shell")
    if fso.FileExists(file1) then
    if fso.FileExists(file2) then
    if fso.FileExists(file3) then
    temp = fso.GetTempName
    set oExec = wshShell.Exec("%comspec% /c copy " & file1 & "+" & file2
    & "+" & file3 & " " & temp)
    do while oExec.status = 0
    wscript.sleep 100
    loop
    if fso.FileExists(t) then
    fso.DeleteFile(t)
    end if
    fso.MoveFile temp, t
    end if
    end if
    end if
    wscript.echo temp
    end sub

    appendit "f1.txt","f2.txt","f3.txt","f4.txt"

    f4.txt would be replace with the file you wanted to end up with, however, I
    wouldn't use this for XML files.

    --
    Roland Hall
    /* This information is distributed in the hope that it will be useful, but
    without any warranty; without even the implied warranty of merchantability
    or fitness for a particular purpose. */
    Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
    WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
    MSDN Library - http://msdn.microsoft.com/library/default.asp
    Roland Hall, Jun 27, 2005
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kathy Burke
    Replies:
    2
    Views:
    5,143
    Kevin Spencer
    Aug 1, 2003
  2. Showjumper
    Replies:
    2
    Views:
    1,805
    Showjumper
    Aug 2, 2003
  3. Imran Aziz
    Replies:
    4
    Views:
    8,698
    ljenner01
    Jan 19, 2011
  4. keithb
    Replies:
    3
    Views:
    18,573
    =?ISO-8859-1?Q?G=F6ran_Andersson?=
    May 7, 2006
  5. Replies:
    0
    Views:
    893
Loading...

Share This Page