ImgMetadataRemover/Image/OriginalFilenameOutputFormatter.cs
2022-01-22 19:06:10 +02:00

27 lines
No EOL
795 B
C#

using System.IO;
namespace Image
{
public class OriginalFilenameOutputFormatter : IOutputFormatter
{
private readonly string _rootDirectory;
public OriginalFilenameOutputFormatter(string rootDirectory)
{
if (!Directory.Exists(rootDirectory)) Directory.CreateDirectory(rootDirectory);
_rootDirectory = rootDirectory;
}
public string FormatOutputPath(string filePath)
{
var fileName = Path.GetFileName(filePath);
var path = Path.Join(_rootDirectory, $"{fileName}.jpg");
return path;
}
public static OriginalFilenameOutputFormatter Create(string rootDirectory)
{
return new OriginalFilenameOutputFormatter(rootDirectory);
}
}
}