Added DefaultPath static Property to support custom default tmp path

master
Harald Wolff 2023-08-14 20:21:10 +02:00
parent c0f39a81a8
commit 80873d4e71
1 changed files with 4 additions and 4 deletions

View File

@ -7,6 +7,7 @@ namespace ln.templates.service
{
public class TempFileStream : FileStream, IDisposable
{
public static string DefaultPath { get; set; } = Path.GetTempPath();
public new void Dispose()
{
try
@ -21,18 +22,17 @@ namespace ln.templates.service
}
public TempFileStream()
:base($"{GetUniqueFileName(Path.GetTempPath())}", FileMode.Create)
:base($"{GetUniqueFileName(DefaultPath)}", FileMode.Create)
{
}
public TempFileStream(string extension)
:base($"{GetUniqueFileName(Path.GetTempPath(), extension)}", FileMode.Create)
:base($"{GetUniqueFileName(extension)}", FileMode.Create)
{
}
public static string GetUniqueFileName(string path) => GetUniqueFileName(path, "");
public static string GetUniqueFileName(string path) => GetUniqueFileName(path, DefaultPath);
public static string GetUniqueFileName(string path, string extension)
{
return String.Format("{1}/tmp.{2}{0}",