This repository has been archived on 2022-08-05. You can view files and clone it, but cannot push or open issues or pull requests.
CC-Functions/Misc/IO.cs
2020-05-23 17:22:45 +02:00

35 lines
1.2 KiB
C#

using System;
using System.IO;
namespace CC_Functions.Misc
{
/// <summary>
/// IO functions
/// </summary>
public static class IO
{
/// <summary>
/// Recursively gets the size of an directory
/// </summary>
/// <param name="path">The path of the directory</param>
/// <returns>The size of the directory</returns>
public static long GetDirectorySize(string path)
{
string[] a = Directory.GetFiles(path, "*.*", SearchOption.AllDirectories);
long size = 0;
foreach (string t in a)
size += new FileInfo(t).Length;
return size;
}
/// <summary>
/// Check whether the paths are equivalent (ignores case)
/// </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>
public static bool CheckPathEqual(string path1, string path2) =>
Path.GetFullPath(path1)
.Equals(Path.GetFullPath(path2), StringComparison.InvariantCultureIgnoreCase);
}
}