国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

C#:獲得文件版本信息及只讀文件的刪除

2024-07-21 02:18:42
字體:
來源:轉載
供稿:網友
author:david euler
date: 2004/11/16
email:[email protected]

有任何問題,請與我聯系:)

獲取文件的版本信息:
fileversioninfo myfileversioninfo1 = fileversioninfo.getversioninfo("d://test.dll");
textbox1.text="版本號: " + myfileversioninfo1.fileversion;


更改文件屬性,刪除只讀文件:
下例欲將e:/test.txt文件拷貝至d:/tmp/test.txt,但d:/tmp/test.txt已經存在。
//file.copy(sourcefile,destinationfile,true); 用來拷貝文件
//當destinationfile已經存在時,無法將文件file1拷貝到目標文件,
//因此先刪除destination文件,file.delete()方法不能刪除只讀文件,
//因此,如果文件屬性為只讀(attributes屬性中會包含有"readonly"),
//先把文件屬性重置為normal,然后再刪除:
string file1="e://test.txt";
string destinationfile="d://tmp//test.txt";
if(file.exists(destinationfile))
{
fileinfo fi=new fileinfo(destinationfile);
if(fi.attributes.tostring().indexof("readonly")!=-1)
fi.attributes=fileattributes.normal;
file.delete(destinationfile);
}
file.copy(file1,destinationfile,true);



發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 宁国市| 五家渠市| 新沂市| 广昌县| 攀枝花市| 红原县| 昌邑市| 湛江市| 甘南县| 黄平县| 榆社县| 吉安市| 达孜县| 丰台区| 天气| 拜城县| 贞丰县| 信宜市| 黑河市| 柳林县| 佛教| 双峰县| 德钦县| 上高县| 山阳县| 修水县| 同心县| 保康县| 哈巴河县| 乳山市| 铜山县| 乐清市| 汤阴县| 西藏| 长治县| 镇康县| 新乡县| 和平县| 望奎县| 富锦市| 锡林郭勒盟|