FileUtils.cs 867 B

1234567891011121314151617181920212223242526272829303132333435
  1. namespace AipGateway.AIP.Service.Utils
  2. {
  3. public static class FileUtils
  4. {
  5. public static string GetFileData(string fileName)
  6. {
  7. string result = string.Empty;
  8. try
  9. {
  10. if (File.Exists(fileName))
  11. {
  12. byte[] fileBytes = File.ReadAllBytes(fileName);
  13. result = Convert.ToBase64String(fileBytes);
  14. }
  15. }
  16. catch (Exception)
  17. {
  18. return string.Empty;
  19. }
  20. return result;
  21. }
  22. public static void DeleteFile(string fileName)
  23. {
  24. try
  25. {
  26. if (File.Exists(fileName))
  27. {
  28. //File.Delete(fileName);
  29. }
  30. }
  31. catch (Exception) { }
  32. }
  33. }
  34. }