C 檔案操作工具類

2022-02-24 19:13:21 字數 3407 閱讀 4536

using

system;

using

system.collections.generic;

using

system.linq;

using

system.text;

using

system.io;

namespace

readlog.public

;

#region 讀取檔案 +string readfile(string path)

//////讀取檔案

/// ///

檔案路徑

public

string readfile(string

path)

#endregion

#region 刪除資料夾下面所有檔案 void deleteall(string delpath, string geshi)

//////刪除資料夾下面所有檔案

///

///待刪除檔案路徑

///刪除到的新目錄

///操作檔案的格式 例如:*.png、*.xml

public

void deleteall(string delpath, string

geshi)

}#endregion

#region 複製資料夾下面所有檔案 +void copyall(string oldpngpath, string newpngpath, string geshi)

//////複製資料夾下面所有檔案

///

///待複製檔案路徑

///複製到的新目錄

///操作檔案的格式 例如:*.png、*.xml

public

void copyall(string oldpngpath, string newpngpath, string

geshi)

}#endregion

#region 移動資料夾下的所有檔案 void moveall(string olderpath, string topath)

//////移動資料夾下的所有檔案

///

///待移動的檔案目錄

///新目錄

public

void moveall(string olderpath, string

topath)

}#endregion

#region 獲取乙個資料夾下面所有檔案 +string getallfiles(string path, string geshi)

//////獲取乙個資料夾下面所有檔案

/// ///

///檔案型別

///public

string getallfiles(string path, string

geshi)

#endregion

#region 複製單個檔案 + void copyonefile(string oldfilepath, string newfilepath)

//////複製單個檔案

/// ///

檔案原來的全路徑

///檔案新的全路徑

public

void copyonefile(string oldfilepath, string newfilepath, string

newfilename)

file.copy(oldfilepath, newfilepath +newfilename);

}#endregion

#region 移動乙個檔案 + void moveonefile(string oldfilepath, string newfilepath)

//////移動乙個檔案

/// ///

檔案原來的全路徑

///檔案新的全路徑

public

void moveonefile(string oldfilepath, string newfilepath, string

newfilename)

file.move(oldfilepath, newfilepath +newfilename);

}#endregion

#region 刪除乙個檔案 +void deleteonefile(string oldfilepath)

//////刪除乙個檔案

/// ///

檔案路徑

public

void deleteonefile(string

oldfilepath)

#endregion

#region 讀取目錄的時候進行的提示

public

void readfilelogonly(string

path)

目錄中", path));

if (!directory.exists(path))

不存在", path));

//return;

}

else

訪問正常

", path));}}

public

void readfilelogandcreate(string

path)

目錄", path));

if (!directory.exists(path))

不存在,正在進行建立

", path));

directory.createdirectory(path);

console.writeline(string.format(

"檔案目錄建立成功

", path));

}else

訪問正常

", path));}}

#endregion

#region 獲取問價的編碼方式 +system.text.encoding getfileencodetype(string filename)

//////獲取問價的編碼方式

/// ///

檔案路徑

///檔案的編碼方式

public system.text.encoding getfileencodetype(string

filename)

else

if (buffer[0] == 0xfe && buffer[1] == 0xff

)

else

if (buffer[0] == 0xff && buffer[1] == 0xfe

)

else

}else

} #endregion

}}

FastDFS檔案操作工具類

先安裝好伺服器,然後在專案中配置好伺服器的配置 component public class fastdfsutil param multipartfile 檔案物件 return 返回檔案位址 author qbanxiaoli description 上傳檔案 sneakythrows publ...

轉型操作工具類

package org.smart4j.chapter2.util import org.apache.commons.lang3.stringutils created by sunx on 2017 6 28.轉型操作工具類 public final class castutil 轉為strin...

Android SQLITE 操作工具類

首先建立乙個類 databasehelper 繼承sqliteopenhelper幫助類,定義資料庫版本,資料庫名稱,建立表名。private static final int database version 1 資料庫版本號 private static final string databas...