Pchp.Library.PhpPath.tempnam C# (CSharp) Method

tempnam() public static method

Creates a file with a unique path in the specified directory. If the directory does not exist, tempnam() may generate a file in the system's temporary directory, and return the name of that.
public static tempnam ( string dir, string prefix ) : string
dir string The directory where the temporary file should be created.
prefix string The prefix of the unique path.
return string
        public static string tempnam(string dir, string prefix)
        {
            throw new NotImplementedException();
            //// makes "dir" a valid directory:
            //if (string.IsNullOrEmpty(dir) || !System.IO.Directory.Exists(dir))
            //    dir = Path.GetTempPath();

            //// makes "prefix" a valid file prefix:
            //if (prefix == null || prefix.Length == 0 || prefix.IndexOfAny(Path.GetInvalidPathChars()) >= 0)
            //    prefix = "tmp_";

            //string path = Path.Combine(dir, prefix);
            //string result;

            //for (;;)
            //{
            //    result = String.Concat(path, Interlocked.Increment(ref _tempCounter), ".tmp");
            //    if (!File.Exists(result))
            //    {
            //        try
            //        {
            //            File.Open(result, FileMode.CreateNew).Close();
            //            break;
            //        }
            //        catch (UnauthorizedAccessException)
            //        {
            //            // try system temp directory:
            //            dir = Path.GetTempPath();
            //            path = Path.Combine(dir, prefix);
            //        }
            //        catch (PathTooLongException e)
            //        {
            //            PhpException.Throw(PhpError.Notice, PhpException.ToErrorMessage(e.Message));
            //            return Path.GetTempFileName();
            //        }
            //        catch (Exception)
            //        {
            //        }
            //    }
            //}

            //return result;
        }