将 Visual Studio 文件夹结构导出到 Excel
Export Visual Studio folder structure into Excel
有没有办法将 Visual Studio "Solution Explorer" 结构导出到 excel 中?
我试过 "tree" 命令并通过 Windows 命令提示符剪辑它,如下所示:
但要拆分到每笔 Excel 销售并不困难。
我期待这样的结果:
有什么好主意吗?
谢谢。
这里有一个解决方案。以你想要的格式列出文件的简单递归解决方案
public class GetFilesTreeList
{
private static List<Files> files = new List<Files>();
public static void Main(string[] args)
{
var path = @"C:\Users\Lukasz\Desktop";
files.Add(new Files(Path.GetFileName(path), 0));
WriteFilesRec(path, 1);
foreach (var filese in files)
{
Console.WriteLine(filese);
}
}
public class Files {
public int column;
public string name;
public Files(string name, int column)
{
this.column = column;
this.name = name;
}
public override string ToString()
{
return new String('+', column) + name;
}
}
public static void WriteFilesRec(string path, int i) {
DirectoryInfo directory = new DirectoryInfo(path);
foreach(var d in directory.GetDirectories()) {
files.Add(new Files(d.Name, i));
WriteFilesRec(Path.Combine(path, d.Name), i+1);
}
foreach(var f in directory.GetFiles()) {
files.Add(new Files(f.Name, i));
}
}
}
有没有办法将 Visual Studio "Solution Explorer" 结构导出到 excel 中?
我试过 "tree" 命令并通过 Windows 命令提示符剪辑它,如下所示:
但要拆分到每笔 Excel 销售并不困难。 我期待这样的结果:
有什么好主意吗?
谢谢。
这里有一个解决方案。以你想要的格式列出文件的简单递归解决方案
public class GetFilesTreeList
{
private static List<Files> files = new List<Files>();
public static void Main(string[] args)
{
var path = @"C:\Users\Lukasz\Desktop";
files.Add(new Files(Path.GetFileName(path), 0));
WriteFilesRec(path, 1);
foreach (var filese in files)
{
Console.WriteLine(filese);
}
}
public class Files {
public int column;
public string name;
public Files(string name, int column)
{
this.column = column;
this.name = name;
}
public override string ToString()
{
return new String('+', column) + name;
}
}
public static void WriteFilesRec(string path, int i) {
DirectoryInfo directory = new DirectoryInfo(path);
foreach(var d in directory.GetDirectories()) {
files.Add(new Files(d.Name, i));
WriteFilesRec(Path.Combine(path, d.Name), i+1);
}
foreach(var f in directory.GetFiles()) {
files.Add(new Files(f.Name, i));
}
}
}