Directory/File .Move
This commit is contained in:
parent
a76077de99
commit
2db018c54b
@ -2,7 +2,7 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<!--package info-->
|
<!--package info-->
|
||||||
<PackageId>DTLib</PackageId>
|
<PackageId>DTLib</PackageId>
|
||||||
<Version>1.2.0</Version>
|
<Version>1.2.1</Version>
|
||||||
<Authors>Timerix</Authors>
|
<Authors>Timerix</Authors>
|
||||||
<Description>Library for all my C# projects</Description>
|
<Description>Library for all my C# projects</Description>
|
||||||
<RepositoryType>GIT</RepositoryType>
|
<RepositoryType>GIT</RepositoryType>
|
||||||
|
|||||||
@ -46,6 +46,17 @@ public static class Directory
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void Move(IOPath current_path, IOPath target_path, bool overwrite)
|
||||||
|
{
|
||||||
|
if (Exists(target_path))
|
||||||
|
{
|
||||||
|
if (overwrite)
|
||||||
|
Delete(target_path);
|
||||||
|
else throw new Exception($"directory {target_path} already exists");
|
||||||
|
}
|
||||||
|
System.IO.Directory.Move(current_path.Str, target_path.Str);
|
||||||
|
}
|
||||||
|
|
||||||
/// удаляет папку со всеми подпапками и файлами
|
/// удаляет папку со всеми подпапками и файлами
|
||||||
public static void Delete(IOPath dir) =>
|
public static void Delete(IOPath dir) =>
|
||||||
System.IO.Directory.Delete(dir.Str, true);
|
System.IO.Directory.Delete(dir.Str, true);
|
||||||
|
|||||||
@ -37,6 +37,17 @@ public static class File
|
|||||||
newFile.Close();
|
newFile.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void Move(IOPath current_path, IOPath target_path, bool overwrite)
|
||||||
|
{
|
||||||
|
if (Exists(target_path))
|
||||||
|
{
|
||||||
|
if (overwrite)
|
||||||
|
Delete(target_path);
|
||||||
|
else throw new Exception($"file {target_path} already exists");
|
||||||
|
}
|
||||||
|
System.IO.File.Move(current_path.Str, target_path.Str);
|
||||||
|
}
|
||||||
|
|
||||||
public static void Delete(IOPath file) => System.IO.File.Delete(file.Str);
|
public static void Delete(IOPath file) => System.IO.File.Delete(file.Str);
|
||||||
|
|
||||||
public static byte[] ReadAllBytes(IOPath file)
|
public static byte[] ReadAllBytes(IOPath file)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user