Added DefaultPath static Property to support custom default tmp path
parent
c0f39a81a8
commit
80873d4e71
|
@ -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}",
|
||||
|
|
Loading…
Reference in New Issue