2015-06-04 13:15:54 -04:00
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
2015-07-15 14:17:19 -04:00
|
|
|
|
using System.Text;
|
2015-06-04 13:15:54 -04:00
|
|
|
|
|
2015-06-26 12:42:20 -04:00
|
|
|
|
namespace Filtration.Common.Services
|
2015-06-04 13:15:54 -04:00
|
|
|
|
{
|
2015-06-26 12:42:20 -04:00
|
|
|
|
public interface IFileSystemService
|
2015-06-04 13:15:54 -04:00
|
|
|
|
{
|
|
|
|
|
string ReadFileAsString(string filePath);
|
|
|
|
|
void WriteFileFromString(string filePath, string inputString);
|
|
|
|
|
bool DirectoryExists(string directoryPath);
|
|
|
|
|
string GetUserProfilePath();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal class FileSystemService : IFileSystemService
|
|
|
|
|
{
|
|
|
|
|
public string ReadFileAsString(string filePath)
|
|
|
|
|
{
|
|
|
|
|
return File.ReadAllText(filePath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void WriteFileFromString(string filePath, string inputString)
|
|
|
|
|
{
|
2015-07-15 14:17:19 -04:00
|
|
|
|
File.WriteAllText(filePath, inputString, Encoding.UTF8);
|
2015-06-04 13:15:54 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool DirectoryExists(string directoryPath)
|
|
|
|
|
{
|
|
|
|
|
return Directory.Exists(directoryPath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string GetUserProfilePath()
|
|
|
|
|
{
|
|
|
|
|
return Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|