2020-03-13 19:19:55 +01:00
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
2019-11-29 21:42:39 +01:00
|
|
|
|
|
2020-09-11 10:38:55 +02:00
|
|
|
|
namespace CC_Functions.Core
|
2019-11-29 21:42:39 +01:00
|
|
|
|
{
|
2020-05-23 15:32:24 +02:00
|
|
|
|
/// <summary>
|
2020-05-23 17:22:45 +02:00
|
|
|
|
/// IO functions
|
2020-05-23 15:32:24 +02:00
|
|
|
|
/// </summary>
|
2019-11-29 21:42:39 +01:00
|
|
|
|
public static class IO
|
|
|
|
|
{
|
2020-05-23 15:32:24 +02:00
|
|
|
|
/// <summary>
|
2020-05-23 17:22:45 +02:00
|
|
|
|
/// Recursively gets the size of an directory
|
2020-05-23 15:32:24 +02:00
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="path">The path of the directory</param>
|
|
|
|
|
/// <returns>The size of the directory</returns>
|
2019-11-29 21:42:39 +01:00
|
|
|
|
public static long GetDirectorySize(string path)
|
|
|
|
|
{
|
2019-12-22 16:58:16 +01:00
|
|
|
|
string[] a = Directory.GetFiles(path, "*.*", SearchOption.AllDirectories);
|
|
|
|
|
long size = 0;
|
2020-05-23 15:32:24 +02:00
|
|
|
|
foreach (string t in a)
|
|
|
|
|
size += new FileInfo(t).Length;
|
2019-12-22 16:58:16 +01:00
|
|
|
|
return size;
|
2019-11-29 21:42:39 +01:00
|
|
|
|
}
|
2020-05-23 17:22:45 +02:00
|
|
|
|
|
2020-05-23 15:32:24 +02:00
|
|
|
|
/// <summary>
|
2020-05-23 17:22:45 +02:00
|
|
|
|
/// Check whether the paths are equivalent (ignores case)
|
2020-05-23 15:32:24 +02:00
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="path1">The first path to check</param>
|
|
|
|
|
/// <param name="path2">The second path to check</param>
|
|
|
|
|
/// <returns>Whether the paths are equal</returns>
|
2020-03-13 19:19:55 +01:00
|
|
|
|
public static bool CheckPathEqual(string path1, string path2) =>
|
|
|
|
|
Path.GetFullPath(path1)
|
|
|
|
|
.Equals(Path.GetFullPath(path2), StringComparison.InvariantCultureIgnoreCase);
|
2019-11-29 21:42:39 +01:00
|
|
|
|
}
|
|
|
|
|
}
|