Open text file and create a new text file

Author Message
baker94

  • Total Posts : 2
  • Scores: 0
  • Reward points : 0
  • Joined: 1/11/2012
  • Status: offline
Open text file and create a new text file Wednesday, January 11, 2012 1:45 AM (permalink)
0
Hi everyone...
 
okay, I have a text file (version.txt) with a single number (ie 704).  I need to open the text file, read the number then create a new text file using that number (704.txt).  I've taken bits of code from different post, but haven't got it to work yet.
 
Thanks,
Kevin
 
#1
    ebgreen

    • Total Posts : 8227
    • Scores: 98
    • Reward points : 0
    • Joined: 7/12/2005
    • Status: offline
    Re:Open text file and create a new text file Wednesday, January 11, 2012 6:09 AM (permalink)
    0
    The first step is to post what you have so far so we can help you sort it out.
    "... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
    Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
    http://www.visualbasicscript.com/m_47117/tm.htm
     
    #2
      nakra

      • Total Posts : 10
      • Scores: 0
      • Reward points : 0
      • Joined: 3/16/2011
      • Status: offline
      Re:Open text file and create a new text file Wednesday, January 11, 2012 6:56 AM (permalink)
      0
      If both the version.txt file and the new file are local on your computer you can use the Scripting.FileSystemObject object, it's simple to work with.
       
      Maybe this script will help you.
       Set objFSO = CreateObject("Scripting.FileSystemObject")
      Set objFile = objFSO.OpenTextFile("version.txt")
      
      ' Read the number
      sLine = objFile.ReadLine
      objFile.Close
      
      ' Create the requested file
      objFSO.CreateTextFile(sLine & ".txt") 

       
      The script assumes that you run it in the same directory where your version.txt file is located, creating the new file in the same directory too.
      If the file is located somewhere else on your local computer, you need to specify the path to it.
       
      #3
        baker94

        • Total Posts : 2
        • Scores: 0
        • Reward points : 0
        • Joined: 1/11/2012
        • Status: offline
        Re:Open text file and create a new text file Thursday, January 12, 2012 12:54 AM (permalink)
        0
        nakra -
         
        worked perfect!  Thanks for the help...
         
        #4

          Online Bookmarks Sharing: Share/Bookmark

          Jump to:

          Current active users

          There are 0 members and 1 guests.

          Icon Legend and Permission

          • New Messages
          • No New Messages
          • Hot Topic w/ New Messages
          • Hot Topic w/o New Messages
          • Locked w/ New Messages
          • Locked w/o New Messages
          • Read Message
          • Post New Thread
          • Reply to message
          • Post New Poll
          • Submit Vote
          • Post reward post
          • Delete my own posts
          • Delete my own threads
          • Rate post

          2000-2012 ASPPlayground.NET Forum Version 3.9