C中常用的經典檔案操作方法

2022-11-28 16:30:09 字數 1568 閱讀 9987

檢視文章

2023年08月17日星期五 10:01

c#追加檔案

streamwriter sw = ".")+"\\");

"追逐理想");

"kzlll");

".net筆記");

c#拷貝檔案

string orignfile,newfile;

orignfile = ".")+"\\";

newfile = ".")+"\\";

c#刪除檔案

string delfile = ".")+"\\";

c#移動檔案

string orignfile,newfile;

orignfile = ".")+"\\";

newfile = ".")+"\\";

c#建立目錄

// 建立目錄c:\sixage

directoryinfo d="c:\\sixage");

// d1指向c:\sixage\sixage1

directoryinfo d1="sixage1");

// d2指向c:\sixage\sixage1\sixage1_1

directoryinfo d2="sixage1_1");

// 將當前目錄設為c:\sixage

"c:\\sixage");

// 建立目錄c:\sixage\sixage2

"sixage2");

// 建立目錄c:\sixage\sixage2\sixage2_1

"sixage2\\sixage2_1");

遞迴刪除資料夾及檔案

<%@ page language=c#%>

<%@ import namespace=""%>

public void deletefolder(string dir)

else

" 該資料夾不存在"); //如果資料夾不存在則提示

} protected void page_load (object sender ,eventargs e)

// 實現乙個靜態方法將指定資料夾下面的所有內容copy到目標資料夾下面

// 如果目標資料夾為唯讀屬性就會報錯。

// april 18april2005 in stu

public static void copydir(string srcpath,string aimpath)

}catch (exception e)

}// 實現乙個靜態方法將指定資料夾下面的所有內容detele

// 測試的時候要小心操作,刪除之後無法恢復。

// april 18april2005 in stu

public static void deletedir(string aimpath)

否則直接delete檔案

else

}//刪除資料夾

.directory .delete (aimpath,true);

}catch (exception e)

}需要引用命名空間:

using

/**////

/////////

C公共類中常用方法總結

using system using using system.linq using system.text using mrcy.baseclass using system.data.sqlclient using system.windows.forms using system.data n...

複製檔案和資料夾的操作方法

複製檔案,複製資料夾,這些複製操使用電腦經常要用到的,複製與移動檔案的區別是,進行複製操作後的檔案或資料夾仍然儲存在原位置,即在原位置和目標位置都存在,而移動後的檔案或資料夾已經不在原位置了。下面以將 dnzs123 資料夾複製到 收藏 資料夾為例一一說明。一.利用右鍵選單複製 這個方法與前面移動資...

招聘中常用性格測試的幾種常用方法經典

一 德國醫生 心理學家 卡雷努思的 四氣質說 1,主要特徵 陽剛的多血質 情緒反映弱而快。平淡的黏液質 情緒反映弱而慢。憂鬱的黑膽質 情緒反映強而慢。急躁的黃膽質 情緒反映強而快。2,性格特點及主要表現 氣質型別 多血質 性格特點 輕率 活潑 好事 喜歡與人交往 典型表現 面對困難不退縮,不會記恨,...