Results 1 to 9 of 9

Thread: [RESOLVED] Generate image path from unique name, what to do with invalid chars?

Hybrid View

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,070

    Re: Generate image path from unique name, what to do with invalid chars?

    Quote Originally Posted by aashish_9601 View Post
    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.

    Quote Originally Posted by danasegarane View Post
    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.

  2. #2
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Generate image path from unique name, what to do with invalid chars?

    Quote Originally Posted by NickThissen View Post
    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

  3. #3
    Frenzied Member MattP's Avatar
    Join Date
    Dec 2008
    Location
    WY
    Posts
    1,227

    Re: Generate image path from unique name, what to do with invalid chars?

    Quote Originally Posted by NickThissen View Post
    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."

    Quote Originally Posted by NickThissen View Post
    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
  •  



Click Here to Expand Forum to Full Width