|
-
Apr 15th, 2010, 06:33 AM
#1
Re: Generate image path from unique name, what to do with invalid chars?
 Originally Posted by aashish_9601
you can asign an unique id to the radio station and use that id as the image name
I thought of that but that is not an option, for other reasons. Perhaps as a last resort.
 Originally Posted by danasegarane
You have this kind of options. You can go for the
Code:
Path.GetTempFileName()
Creates a uniquely named, zero-byte temporary file on disk and returns the full path of that file.
Code:
System.Guid.NewGuid
to get a unique GUID
Or You can use the current time(with seconds) with that RadioButton to create unique id
Code:
System.DateTime.Now.ToString("ddMMyyyhhmmss")
The GetTempFileName creates a filename in the Temp folder, right? I don't want that. I suppose I could always use only the last part of the path (the actual filename), but that would leave me with the same problem I think. I suppose the GetTempFileName generates a unique name in the Temp folder, which doesn't have to be unique in my own folder. So if I take this route I may as well just generate my own random name and hope I never get a conflict.
I'll look into the Guid thing, never used that before.
The time is not an option, because the custom stations are all saved in one go, along with their images, so the images would all have the same timestamp.
-
Apr 15th, 2010, 06:37 AM
#2
Re: Generate image path from unique name, what to do with invalid chars?
 Originally Posted by NickThissen
I thought of that but that is not an option, for other reasons. Perhaps as a last resort.
The time is not an option, because the custom stations are all saved in one go, along with their images, so the images would all have the same timestamp.
But the Seconds will differ.Isn't it ?
Please mark you thread resolved using the Thread Tools as shown
-
Apr 15th, 2010, 11:29 AM
#3
Re: Generate image path from unique name, what to do with invalid chars?
 Originally Posted by NickThissen
The GetTempFileName creates a filename in the Temp folder, right? I don't want that. I suppose I could always use only the last part of the path (the actual filename), but that would leave me with the same problem I think. I suppose the GetTempFileName generates a unique name in the Temp folder, which doesn't have to be unique in my own folder. So if I take this route I may as well just generate my own random name and hope I never get a conflict.
http://msdn.microsoft.com/library/aa364991
"Only the lower 16 bits of the uUnique parameter are used. This limits GetTempFileName to a maximum of 65,535 unique file names if the lpPathName and lpPrefixString parameters remain the same.
Due to the algorithm used to generate file names, GetTempFileName can perform poorly when creating a large number of files with the same prefix. In such cases, it is recommended that you construct unique file names based on GUIDs."
 Originally Posted by NickThissen
I'll look into the Guid thing, never used that before.
This is a very straightforward process.
Code:
Dim uniqueFile As String = String.Format("Img{0}.jpg", Guid.NewGuid.ToString())
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|