ImgMetadataRemover/Image/OriginalFilenameOutputFormatter.cs

27 lines
795 B
C#
Raw Normal View History

2022-01-22 17:06:10 +00:00
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);
}
}
}