Results 1 to 2 of 2

Thread: [RESOLVED] how to dynamically add a file name

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2005
    Location
    Madison, WI
    Posts
    136

    Resolved [RESOLVED] how to dynamically add a file name

    So I am able to write to a .txt file, but I would like to have the file names change depending on the date when the process is run. How would I do this?
    Here is my current code:

    VB Code:
    1. Dim oFile As System.IO.File
    2.         Dim oWrite As System.IO.StreamWriter
    3.         oWrite = oFile.CreateText("C:\New.txt")
    4.         oWrite.WriteLine("This is working great.")
    5.         oWrite.WriteLine()

    Thanks

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: how to dynamically add a file name

    When using dates to identify files, I would suggest you use the format yyyyMMdd, so that sorting the files alphabetically will also sort them chronologically. You would do that something like this:
    VB Code:
    1. oWrite = IO.File.CreateText("C:\" & Date.Today.ToString("yyyyMMdd") & ".txt")
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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