mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-26 03:58:45 +08:00
35 lines
1.1 KiB
C#
35 lines
1.1 KiB
C#
using System.IO;
|
|
|
|
namespace mRemoteNGTests.TestHelpers
|
|
{
|
|
public class FileTestHelpers
|
|
{
|
|
public static void DeleteTestFile(string path)
|
|
{
|
|
if (File.Exists(path))
|
|
File.Delete(path);
|
|
}
|
|
|
|
public static void DeleteFilesInDirectory(string directory, string fileMatching)
|
|
{
|
|
var filesToDelete = Directory.GetFiles(directory, fileMatching, SearchOption.TopDirectoryOnly);
|
|
foreach (var file in filesToDelete)
|
|
if (File.Exists(file))
|
|
File.Delete(file);
|
|
}
|
|
|
|
public static string NewTempFilePath()
|
|
{
|
|
var newPath = Path.Combine(GetAppSpecificTempDirectory(), Path.GetRandomFileName());
|
|
var folderPath = Path.GetDirectoryName(newPath);
|
|
if (!Directory.Exists(folderPath))
|
|
Directory.CreateDirectory(folderPath);
|
|
return newPath;
|
|
}
|
|
|
|
public static string GetAppSpecificTempDirectory()
|
|
{
|
|
return Path.Combine(Path.GetTempPath(), "mRemoteNGTests");
|
|
}
|
|
}
|
|
} |