FileEx.cs 861 B

12345678910111213141516171819202122232425262728293031
  1. using System.IO;
  2. namespace BansheeEngine
  3. {
  4. public static class FileEx
  5. {
  6. public static void Move(string source, string destination)
  7. {
  8. string destParent = PathEx.GetParent(destination);
  9. if (!string.IsNullOrEmpty(destParent))
  10. {
  11. if (!Directory.Exists(destParent))
  12. Directory.CreateDirectory(destParent);
  13. }
  14. File.Move(source, destination);
  15. }
  16. public static void Copy(string source, string destination)
  17. {
  18. string destParent = PathEx.GetParent(destination);
  19. if (!string.IsNullOrEmpty(destParent))
  20. {
  21. if (!Directory.Exists(destParent))
  22. Directory.CreateDirectory(destParent);
  23. }
  24. File.Copy(source, destination);
  25. }
  26. }
  27. }