FileIOProvider.cs 970 B

123456789101112131415161718192021222324252627282930313233343536
  1. /*---------------------------------------------------------------------------------------------
  2. * Copyright (c) Unity Technologies.
  3. * Copyright (c) Microsoft Corporation. All rights reserved.
  4. * Licensed under the MIT License. See License.txt in the project root for license information.
  5. *--------------------------------------------------------------------------------------------*/
  6. using System.IO;
  7. using System.Text;
  8. namespace Microsoft.Unity.VisualStudio.Editor
  9. {
  10. public interface IFileIO
  11. {
  12. bool Exists(string fileName);
  13. string ReadAllText(string fileName);
  14. void WriteAllText(string fileName, string content);
  15. }
  16. class FileIOProvider : IFileIO
  17. {
  18. public bool Exists(string fileName)
  19. {
  20. return File.Exists(fileName);
  21. }
  22. public string ReadAllText(string fileName)
  23. {
  24. return File.ReadAllText(fileName);
  25. }
  26. public void WriteAllText(string fileName, string content)
  27. {
  28. File.WriteAllText(fileName, content, Encoding.UTF8);
  29. }
  30. }
  31. }