Results 1 to 5 of 5

Thread: writing to beginning of file

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2002
    Location
    dfg
    Posts
    7

    writing to beginning of file

    using the
    "open "c:\bla.txt" for append as #1 etc"
    inputs the string at the end of the file

    however, for my purpose it needs to be at the beggining of the file? how do i do this?

    also how do i then remove this string from the beginning and restore it to it's original state?

    the basic idea is to corrupt a file so it is unreadable and then uncorrupt it

    cheers
    ~~~~~~~~~~~~~~~~
    YATTA!

  2. #2
    Dimension
    Guest
    your appending which means your adding to an existing file...try using input.

  3. #3
    Dimension
    Guest
    ^ put #1 "test"

  4. #4

    Thread Starter
    New Member
    Join Date
    Mar 2002
    Location
    dfg
    Posts
    7
    no but whatever method writes to the end of the file. i NEED to write to the beginning but have no idea how
    ~~~~~~~~~~~~~~~~
    YATTA!

  5. #5
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141
    VB Code:
    1. Dim strFile     As String   'the exisiting file
    2. Dim strNewInfo  As String   'the new stuff to save
    3.    
    4.     '   Add the contents of the file to a
    5.     '   string variable.
    6.     Open "C:\TestFile.txt" For Input As #1
    7.        strFile = Input(LOF(1), 1)
    8.     Close #1
    9.      
    10.     '   Open the file and write the new information
    11.     '   to the file followed by the old information.
    12.     Open "C:\TestFile.txt" For Output As #1
    13.         Print #1, strNewInfo & vbCrLf & strFile
    14.     Close #1

Posting Permissions

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



Click Here to Expand Forum to Full Width