請問為何無法開啟唯讀檔? |
答題得分者是:johnnychang
|
pcernet
初階會員 發表:69 回覆:113 積分:41 註冊:2002-11-29 發送簡訊給我 |
|
william
版主 發表:66 回覆:2535 積分:3048 註冊:2002-07-11 發送簡訊給我 |
|
ccchen
版主 發表:61 回覆:940 積分:1394 註冊:2002-04-15 發送簡訊給我 |
引言: var INPUTFILE:file; begin AssignFile(INPUTFILE,'test.exe'); Reset(INPUTFILE,1); closefile(INPUTFILE); end; ======================================== 如果test.exe非唯讀屬性則一切正常,否則出現錯誤 但test.exe如果是在cdrom,勢必唯讀,請問有解嗎? 謝謝!1. filetype改成textfile不要untyped 如下就可以讀readonly var INPUTFILE:textfile; 2. 若以textfile型態無法滿足需求, 那就用 FileStream讀 var fs:TFileStream; begin fs:=TFileStream.create('test.exe',fmOpenRead); try fs.read(buf, count); ... finally fs.free; end; end; |
pcernet
初階會員 發表:69 回覆:113 積分:41 註冊:2002-11-29 發送簡訊給我 |
|
william
版主 發表:66 回覆:2535 積分:3048 註冊:2002-07-11 發送簡訊給我 |
Quoted from the Delphi help: Warning: The default value of FileMode is 2 (Read/Write access). If this is not changed to a read-only file mode before calling Reset, attempts to open read-only files will fail. So you should set the proper FileMode (a global variable in Delphi) before calling reset.
|
johnnychang
一般會員 發表:24 回覆:26 積分:16 註冊:2002-09-27 發送簡訊給我 |
|
pcernet
初階會員 發表:69 回覆:113 積分:41 註冊:2002-11-29 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |