ID Unique

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Hector Martinez

    #1

    ID Unique


    We know, C#, generate a Unique ID, for each visual element incorporate to its form. I need to create a unique ID to name my files, how can I do that, without have to create my own algorithm

    I hope somebody can help me, thanks in advantage

  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: ID Unique

    Hector,

    You can just use a new Guid, and then use the string representation for
    that. That ID is guaranteed to be unique for something like the next 5000
    years if you had generated 1000 per second during that time. It's going to
    be ^pretty^ unique.

    Hope this helps.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m

    "Hector Martinez" <anonymous@disc ussions.microso ft.com> wrote in message
    news:D26594A7-F0AA-4537-B97C-9FC234E5A6D5@mi crosoft.com...[color=blue]
    >
    >
    > We know, C#, generate a Unique ID, for each visual element incorporate[/color]
    to its form. I need to create a unique ID to name my files, how can I do
    that, without have to create my own algorithm.[color=blue]
    >
    > I hope somebody can help me, thanks in advantage.
    >[/color]


    Comment

    • Daniel Billingsley

      #3
      Re: ID Unique

      Another fascinating tidbit about which I've often wondered. :)

      "Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard .caspershouse.c om> wrote in
      message news:O$fkTkqrDH A.2004@TK2MSFTN GP10.phx.gbl...[color=blue]
      > Hector,
      >
      > You can just use a new Guid, and then use the string representation[/color]
      for[color=blue]
      > that. That ID is guaranteed to be unique for something like the next 5000
      > years if you had generated 1000 per second during that time. It's going[/color]
      to[color=blue]
      > be ^pretty^ unique.
      >[/color]


      Comment

      • Michael Giagnocavo [MVP]

        #4
        Re: ID Unique

        If they are temp files, You can use System.IO.Path. GetTempFileName ().
        -mike
        MVP

        "Hector Martinez" <anonymous@disc ussions.microso ft.com> wrote in message
        news:D26594A7-F0AA-4537-B97C-9FC234E5A6D5@mi crosoft.com...[color=blue]
        >
        >
        > We know, C#, generate a Unique ID, for each visual element incorporate[/color]
        to its form. I need to create a unique ID to name my files, how can I do
        that, without have to create my own algorithm.[color=blue]
        >
        > I hope somebody can help me, thanks in advantage.
        >[/color]


        Comment

        Working...