国产探花免费观看_亚洲丰满少妇自慰呻吟_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);



發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 镇坪县| 德昌县| 宜州市| 北安市| 密云县| 盘山县| 紫云| 怀安县| 新巴尔虎左旗| 安化县| 阿合奇县| 太仓市| 卓资县| 锦州市| 和平区| 灵川县| 类乌齐县| 荔浦县| 渭南市| 安丘市| 昌乐县| 甘泉县| 青龙| 阿城市| 石门县| 凤冈县| 井陉县| 梁河县| 镇沅| 普定县| 聊城市| 龙岩市| 龙泉市| 甘南县| 环江| 商城县| 福泉市| 葵青区| 海兴县| 台南县| 唐山市|