using newtonsoft.json;
using system;
using system.collections.generic;
using system.io;
using system.linq;
using system.text;
using system.text.regularexpressions;
using system.threading.tasks;
namespace dataprocess.utils
// delete folders.
string folders = directory.getdirectories(path);
foreach (var folder in folders)
}///
/// 讀取檔案文字內容
///
///
///
public static string readtext (string filepath)
return content;
}///
/// 寫入檔案
///
/// 檔名
/// 待寫入內容
public string removeendbracket(string str)
string outstr = str.replace("(", "(").replace(")", ")");
string patern = @"\([^\(\)年]*?\)";
matchcollection mc = regex.matches(outstr, patern);
if (mc.count == 0)
else
}return outstr;
}///
/// 讀取text檔案,返回list
///
///
///
public static listreadtexttolist(string filename)
sr.close();
return filecontent;
}catch (exception ex)
}public static void writedictofile(dictionary> historycache, string dupcachepath)
}sr.close();
fs.close();
public void writelisttotext(listcontent, string filename)
public static dictionaryreadfiletodic(string path)}}
return dic;
}///
/// 對於乙個鍵可能有多個值的情況
///
///
///
public static dictionary> readmultifiletodic(string path)
else
}sr.close();
}return dic;
}/**
* 獲取資料夾下面全部檔名稱
* **/
public static void director(string dir, listlist)
//獲取子資料夾內的檔案列表,遞迴遍歷
foreach (directoryinfo dd in directs)
public void writefile(string path, string content)
}public static string dictionarytojson(dictionarymydic)
public static dictionaryjsontodictionary(string jsonstr)}}
C 檔案處理 函式
開啟檔案 include file fp fp fopen file.txt r if null fp 獲取檔案大小fseek fp,0l,seek end 定位至檔案結尾 filelen ftell fp 得到檔案位元組數 p char malloc filelen 1 分配空間大小要 1 nul...
檔案處理相關C函式
總覽 1.0 int fscanf file stream,const char format,argument waiting for adding 1.0.0 fscanf 函式原型為 int fscanf file stream,const char format,argument 其功能為根...
php 常用檔案處理函式 與 檔案上傳
php 檔案處理 檔案寫入 fwrite 向檔案寫入內容,可安全用於二進位制檔案 file put contents 向檔案寫入內容,等同依次呼叫 fopen,fwrite 以及 fclose 函式。file put contents test.txt this is something.檔案讀取 ...