FileIO.cs 845 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. using System.IO;
  2. using System.Text;
  3. namespace VSCodeEditor
  4. {
  5. public interface IFileIO
  6. {
  7. bool Exists(string fileName);
  8. string ReadAllText(string fileName);
  9. void WriteAllText(string fileName, string content);
  10. void CreateDirectory(string pathName);
  11. }
  12. class FileIOProvider : IFileIO
  13. {
  14. public bool Exists(string fileName)
  15. {
  16. return File.Exists(fileName);
  17. }
  18. public string ReadAllText(string fileName)
  19. {
  20. return File.ReadAllText(fileName);
  21. }
  22. public void WriteAllText(string fileName, string content)
  23. {
  24. File.WriteAllText(fileName, content, Encoding.UTF8);
  25. }
  26. public void CreateDirectory(string pathName)
  27. {
  28. Directory.CreateDirectory(pathName);
  29. }
  30. }
  31. }