Anon,
String.Format expects a format specifier and zero or more arguments
(ParamArray).
The format specifier is a string that has zero or more placeholders (one for
each argument). The place holders are in curly braces {}. The number
indicates which argument to use. The info after the : in the curly braces is
used to format the argument. In this case argument zero is a date, so info
specifies a custom date format. The custom date format "yyyyMMdd" says we
want a 4 digit year, a 2 digit month, and a 2 digit day. Basically
String.Format takes the format from the placeholder & calls ToString with
the format, as my second example is doing directly.
The second link (along with its sub topics) should explain in detail how
both work.
Jay
"Anon" <an**@anon.com> wrote in message
news:eY**************@TK2MSFTNGP09.phx.gbl...
Wow, i used the first response first and it worked great and my next
question was what it all meant. I understand, just not 100%, thanks for
the links and all of the help!!
Luis
Jay B. Harlow [MVP - Outlook] wrote:
Anon,
I would use a format string such as:
Const format As String = "{0:yyyyMMdd}.txt"
Dim theDate As DateTime = DateTime.Now
Dim szFilename As String = String.Format( format, theDate)
Alternatively you could use:
Dim szFilename = theDate.ToString("yyyyMMdd") & ".txt"
For details on custom datetime formats see:
http://msdn.microsoft.com/library/de...matstrings.asp
For information on formatting in .NET in general see:
http://msdn.microsoft.com/library/de...ttingtypes.asp
Hope this helps
Jay
"Anon" <an**@anon.com> wrote in message
news:OC*************@TK2MSFTNGP11.phx.gbl...
Hello All!
I have written a simple app that auto downloads a file from a secure ftp,
renames it, and moves it to a network location. Everything works great
except the renaming part. I parse out the last write date to get the new
filename, but the days and month are only single digits! This is a
problem when you reach something like 01/11/2004 and 11/1/2004, I get dup
filenames! ie.. 2004111.txt.
any idea on how I can rename these files with 2 digit values?
TIA
Luis