Filtration/Filtration.Common/Services/FileSystemService.cs

38 lines
998 B
C#
Raw Normal View History

2015-06-04 18:15:54 +01:00
using System;
using System.IO;
2015-07-15 19:17:19 +01:00
using System.Text;
2015-06-04 18:15:54 +01:00
2015-06-26 17:42:20 +01:00
namespace Filtration.Common.Services
2015-06-04 18:15:54 +01:00
{
2015-06-26 17:42:20 +01:00
public interface IFileSystemService
2015-06-04 18:15:54 +01: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 19:17:19 +01:00
File.WriteAllText(filePath, inputString, Encoding.UTF8);
2015-06-04 18:15:54 +01:00
}
public bool DirectoryExists(string directoryPath)
{
return Directory.Exists(directoryPath);
}
public string GetUserProfilePath()
{
return Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
}
}
}