Results 1 to 2 of 2

Thread: Text Files

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2000
    Location
    Glasgow, Scotland
    Posts
    71

    Text Files

    Hi,

    I am trying to do two function with a file, I do not want to use the FSO.

    I need to copy a file from one location to another and I also want to open an existing text file and insert a single line of text at the top of the file.

    Thanks for any help,

    Chris

  2. #2
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    VB Code:
    1. ''  to move a file, you can use FileCopy and then Kill
    2. FileCopy sourcePath, destPath
    3. Kill sourcePath
    4.  
    5.  
    6. ''  insert line at top
    7. Open "c:\someFile.txt" For Binary As #1
    8.     Dim strBuff As String: strBuff = Space(Lof(1))
    9.     Get #1, , strBuff  
    10. Close #1
    11. Open "c:\someFile.txt" For Output As #1
    12.     Print #1, "this is the first line"
    13.     Print #1, strBuff  '' this is the rest of the file
    14. Close #1
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

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