Solved

The local computer time including seconds

Posted on 2006-10-19
4
146 Views
Last Modified: 2010-04-23
Hi,

I need to create a unique filename based on the exact time ie;

03:13

to this...

031334

This is for a unique filename.
0
Comment
Question by:nickmarshall
4 Comments
 
LVL 10

Expert Comment

by:Kinger247
ID: 17764525
Could try something like :

        Dim FileName As String
        Dim RND As New System.Random

        FileName = Now.Hour.ToString.PadLeft(2, "0"c) & Now.Minute.ToString.PadLeft(2, "0"c) & Now.Second.ToString.PadLeft(2, "0"c) & RND.Next(1, 1000)

        Console.WriteLine(FileName)

this also adds a random number at the end ..
0
 
LVL 3

Expert Comment

by:herreruud
ID: 17764616
Dim sFolderPath As String = "C:\Test"
Dim sFileName As String = String.Format("{0}\{1}.extention",sFolderPath,now.Ticks.ToString)
0
 
LVL 1

Author Comment

by:nickmarshall
ID: 17764975
Hi,

thanks for this.  Would I also be able to add in front the date in numerices ie; 01112006
0
 
LVL 18

Accepted Solution

by:
Ravi Singh earned 50 total points
ID: 17765096
Try:

Dim FileName As String = Now.ToString("ddMMyyyy hhmmss")

(You can remove the space in the ToString parameter if you dont want to seperate the date and time...)
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question