簡易資料夾樹形文字檔案生成器

2021-05-21 22:06:50 字數 1057 閱讀 3458

呼叫:directorytreebuilder builder=new directorytreebuilder();

builder.createtreetextfile("-");

1. directorythreenode.cs

using system;

using system.collections;

namespace crl.control}}

2. directorythreebuilder.cs

using system;

using system.componentmodel;

using system.drawing;

using system.windows.forms;

using system.io;

using system.text;

namespace crl.control

/r/n";

private const string columns="層級|序號|檔名稱|檔案型別|檔案大小|修改時間";

private string title=string.format(format,columns.split('|'));

public directorythreebuilder()

{}public string formatcontinuousstring(string format,int len)

///

/// 獲取遞迴列舉的資料夾樹結構文字

///

public void formatdirectorytreetext(string srcpath,string currentpath,string split,ref streamwriter builder,directorytreenode tree)

{string dirs=directory.getdirectories(currentpath);

string files=directory.getfiles(currentpath);

int level=1;

for(int i=0;i

Matlab 資料夾讀取以及文字檔案轉碼

先交代一下背景,工作需要,開發環境發生了變更,數十個程式源 全部亂碼,小廠ide只支援一種編碼 身為程式設計師,讓我乙個個檔案新建 複製 貼上是不存在的,祭出我的matlab才是王道。第一步,先把所有文字檔案讀出來。f dir startpath 檢視結果,沒有問題,返回值是結構體,每個檔案對應乙個...

QT學習 建立資料夾以及文字檔案的讀寫

最近做乙個工程需要記錄日誌,限於硬體問題無法使用資料庫一類的,故決定採用txt檔案儲存日誌資訊。這裡需要對每乙個使用者建立乙個資料夾,在qt裡面可以這樣寫 qdir dir if dir.exists dirname dirname即為你要建立的資料夾名字 dir.mkdir dirname 這樣建...

python 生成文字檔案 43

import os def get fname while true fname input filename if not os.path.exists fname os.path.exists 檢視檔案是否存在 break print s already exists.try again fna...