Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Renaming a text file to a previous date 1

Status
Not open for further replies.

arodri

Technical User
Jul 9, 2010
121
US
Hello,

I'm new to VB and have a pretty simple task that I need some help with. I'm building a visual studio DTSX package and I need to create new text files from scratch, and name them with today's date minus 7 days. So here's the code I have for creating a new text file, which works fine:

Dim file As System.IO.FileStream
file = System.IO.File.Create("d:\test.txt")


The problem I'm having is renaming the files (there will be two. I don't know what the script would look like for this. I want to create a seperate script for renaming the files, and they should be named something like:

CustData June 22,2011
TransData June 22,2011

The CustData and TransData part of the name will always be the same - so the only thing that will change is the date. So if the task runs tomorrow, the names should be:
CustData June 23,2011
TransData June 23,2011

And so on.

Thanks!

 
Is this you are looking for?
Code:
        Dim dt As String = Format(DateAdd(DateInterval.Day, -7, Date.Today), "MMMM dd,yyyy")
        Dim fileName As String = "CustData " & dt & " TansData " & dt & ".txt"
        MessageBox.Show(fileName)


Zameer Abdulla
 
That's EXACTLY what I was looking for. Thank you so much!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top