VRCMelonAssistant/VRCMelonAssistant/Classes/Diagnostics.cs

59 lines
1.7 KiB
C#
Raw Normal View History

2019-04-22 18:41:43 +12:00
using System.Collections.Generic;
using System.IO;
using System.Windows;
namespace VRCMelonAssistant
2019-04-22 18:41:43 +12:00
{
class Diagnostics
{
public static string[] ReadFolder(string path, int level = 0)
{
List<string> entries = new List<string>();
foreach (string file in Directory.GetFileSystemEntries(path))
{
2020-02-02 21:42:15 +13:00
string line = string.Empty;
2019-04-22 18:41:43 +12:00
if (File.Exists(file))
{
2020-02-03 00:04:30 +13:00
line = Utils.CalculateMD5(file) + " " + LevelSeparator(level) + "├─ " + Path.GetFileName(file);
2019-04-22 18:41:43 +12:00
entries.Add(line);
}
else if (Directory.Exists(file))
{
line = Utils.Constants.MD5Spacer + LevelSeparator(level) + "├─ " + Path.GetFileName(file);
entries.Add(line);
foreach (string entry in ReadFolder(file.Replace(@"\", @"\\"), level + 1))
{
//MessageBox.Show(entry);
entries.Add(entry);
}
}
else
{
MessageBox.Show("! " + file);
}
}
if (entries.Count > 0)
2020-11-17 03:19:59 +13:00
{
2019-04-22 18:41:43 +12:00
entries[entries.Count - 1] = entries[entries.Count - 1].Replace("├", "└");
2020-11-17 03:19:59 +13:00
}
2019-04-22 18:41:43 +12:00
return entries.ToArray();
}
private static string LevelSeparator(int level)
{
2020-02-02 21:42:15 +13:00
string separator = string.Empty;
2020-02-03 00:04:30 +13:00
for (int i = 0; i < level; i++)
2019-04-22 18:41:43 +12:00
{
2020-02-02 21:38:29 +13:00
separator += "│ ";
2019-04-22 18:41:43 +12:00
}
return separator;
}
}
}