Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Unique Filename
Message
De
14/10/2005 11:12:46
 
 
À
14/10/2005 05:26:52
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Titre:
Divers
Thread ID:
01058916
Message ID:
01059169
Vues:
18
Thanks, that is what I needed. Sometimes it is difficult to locate the correct method in the .NET framework. I would have beleived it would have been in the System.IO.File namespace, not the .Path.

>Greg,
>
>You could try using the following from the System.IO namespace.
>
>string TempFilename = System.IO.Path.GetTempFileName();
>
>However this will return a unique temporary filename but it also creates an empty file on disk (zero bytes) which is okay if you are prepared to manage deletion or re-use yourself. This method is actually making the following call to managed code.
>
>[DllImport("kernel32.dll", CharSet=CharSet.Auto, SetLastError=true)]
>internal static extern uint GetTempFileName(string tmpPath, string prefix, uint uniqueIdOrZero, StringBuilder tmpFileName);
>
>public static string GetTempFileName()
>{
>   string text1 = Path.GetTempPath();
>   StringBuilder builder1 = new StringBuilder(260);
>   uint num1 = Win32Native.GetTempFileName(text1, "tmp", 0, builder1);
>
>   if (num1 == 0)
>   {
>         __Error.WinIOError();
>   }
>
>   return builder1.ToString();
>}
>
>
>However I would not use this if your requirements involve multiple threads and avoiding race conditions then Cetin's idea of using a GUID is a much more reliable solution.
>
>Regards
>Neil
Greg Reichert
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform