private void EnsureDir() { // For performance reasons, we only want to check // the directory once. if (mDirectoryCreated) { return; } var dir = Path.GetDirectoryName(TempPath); FileEx.EnsureDirectory(dir); mDirectoryCreated = true; }
/// <summary> /// Creates an instance of TempFile. /// </summary> /// <param name="dir">The path to the directory.</param> /// <param name="template">The template for the file name. Place a {0} where the counter should go (ex, MyPicture{0}.jpg).</param> public TempFile(string dir, string template) { TempPath = FileEx.GetUniqueFileName(dir, template); }
/// <summary> /// Creates an instance of TempFile. /// </summary> /// <param name="ext">The extension for the file.</param> public TempFile(string ext) { TempPath = FileEx.GetUniqueFileName(ext); }
/// <summary> /// Creates an instance of TempFile. /// </summary> public TempFile() { TempPath = FileEx.GetUniqueFileName(); }
/// <summary> /// Deletes the temp file if it exists. /// </summary> public void Delete() { FileEx.DeleteFile(TempPath); }