檔案大小問題 |
尚未結案
|
kamiche
一般會員 發表:5 回覆:5 積分:2 註冊:2003-04-06 發送簡訊給我 |
各位大大,小弟有個問題想請教,就是從檔案內容看檔案大小時,明明寫大小 34.0 KB (34,820 位元組),為甚麼從ULTRAEDIT看卻有位置標示居然有34855的大小,小弟不才就用下列方式將A檔案讀出再寫入B檔案,居然後面最後面還是有不一樣,請教這是哪邊出問題? assignfile(Afile,fAname);
Reset(Afile,1);
assignfile(Bfile,fBname);
Rewrite(Bfile,1);
while Not Eof(Afile) do
Begin
Blockread(afile, a, 1);
BlockWrite(Bfile, a, sizeof(a) );
End;
Closefile(bfile);
Closefile(afile); A檔案: http://home.pchome.com.tw/cool/kamichen/A.BMD
PS:PCHOME在檔案最前面有加了一些東西,所以檔案大小變了
|
tonytop
中階會員 發表:6 回覆:114 積分:89 註冊:2003-12-04 發送簡訊給我 |
|
kamiche
一般會員 發表:5 回覆:5 積分:2 註冊:2003-04-06 發送簡訊給我 |
|
tonytop
中階會員 發表:6 回覆:114 積分:89 註冊:2003-12-04 發送簡訊給我 |
天才,您的指令下錯了,我用delphi的範例改成下列程式,copy出
來的檔案和原來的一模一樣,最後面沒有多東東,另外您沒有移動
檔案指標,用Eof(Afile)會跑不完,成為無窮迴圈喔!
var Afile, Bfile:File; a:array[1..2048] of Char; NumRead, NumWritten:Integer; fAname, fBname:String; begin fAname:='c:\A.BMD'; fBname:='c:\B.BMD'; assignfile(Afile, fAname); Reset(Afile, 1); assignfile(Bfile, fBname); Rewrite(Bfile, 1); repeat Blockread(afile, a, SizeOf(a), NumRead); BlockWrite(Bfile, a, NumRead, NumWritten); until (NumRead=0)or(NumWritten<>NumRead); Closefile(bfile); Closefile(afile); |
kamiche
一般會員 發表:5 回覆:5 積分:2 註冊:2003-04-06 發送簡訊給我 |
|
tonytop
中階會員 發表:6 回覆:114 積分:89 註冊:2003-12-04 發送簡訊給我 |
我剛試把a變數宣告成BYTE後寫到B檔案,用ULTRAEDIT的「比較檔案」功能,
得到的結果還是一模一樣耶,是否你有部份作法造成不同呢?
procedure TForm1.Button2Click(Sender: TObject); var Afile, Bfile:File; a:array[1..2048] of Byte; ////// NumRead, NumWritten:Integer; fAname, fBname:String; begin fAname:='c:\A.BMD'; fBname:='c:\B.BMD'; assignfile(Afile, fAname); Reset(Afile, 1); assignfile(Bfile, fBname); Rewrite(Bfile, 1); repeat Blockread(afile, a, SizeOf(a), NumRead); BlockWrite(Bfile, a, NumRead, NumWritten); until (NumRead=0)or(NumWritten<>NumRead); Closefile(bfile); Closefile(afile); end;我正確的mail:h832214@hotmail.com |
kamiche
一般會員 發表:5 回覆:5 積分:2 註冊:2003-04-06 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |