System.IO.Path.GetTempPath C# (CSharp) Méthode

GetTempPath() public static méthode

public static GetTempPath ( ) : string
Résultat string
        public static string GetTempPath()
        {
            StringBuilder sb = StringBuilderCache.Acquire(MaxPath);
            uint r = Interop.Kernel32.GetTempPathW(MaxPath, sb);
            if (r == 0)
                throw Win32Marshal.GetExceptionForLastWin32Error();
            return GetFullPath(StringBuilderCache.GetStringAndRelease(sb));
        }

Usage Example

Exemple #1
0
        /// <summary>
        /// Returns a temp <see cref="T:System.Uri"/>.
        /// </summary>
        /// <returns>
        /// A <see cref="T:System.Uri" /> file.
        /// </returns>
        public static Uri GetUniqueTempRandomFile()
        {
            Logger.Instance.Debug("");
            Logger.Instance.Debug(" Assembly: iTin.Core.IO, Namespace: iTin.Core.IO, Class: File");
            Logger.Instance.Debug($" Returns a temp {typeof(Uri)}");
            Logger.Instance.Debug($" > Signature: ({typeof(Uri)}) GetUniqueTempRandomFile()");

            string tempPath       = NativePath.GetTempPath();
            string randomFileName = NativePath.GetRandomFileName();
            string path           = NativePath.Combine(tempPath, randomFileName);

            Logger.Instance.Debug($"  > Output: {path}");

            return(new Uri(path));
        }
All Usage Examples Of System.IO.Path::GetTempPath