小弟是菜鸟类一员,最近在搞一个自创式小玩意,需要用到读写文件,看了很多实例,都没有提到如何读写二进制文件,请高手们用实例指点。
解决方案 »
- 急救!!接收一定量的请求后,socket服务端不能再与客户端建立连接。
- 一个关于timer使用的问题,我都改了两天了,就是出不来预想的结果,请问究竟哪里有问题,高手指点一二啊!!!
- 我的电脑连接了个adsl猫,请问那个usb延长线可以最长多长?
- 問:寫遊戲外掛程序要用哪些東西?分不夠開新貼加分
- 一个关于 窗体自适应放大的普遍问题,不知道为什么没人问
- 我自己的create方法怎么不行?
- 在delphi中crystal reports报表的制作如何实现
- 如何编写电子邮件发送程序?急救!!!
- !!!这已经是第三次了,为什么所有的Delphi下载点都无法下载?150求购!
- 程序运行时两个form一先一后出来,而并没有在任何一个form的onshow事件或者oncreat事件加form.show,还有没有其他的原因?
- 超难问题!!!!!!!! 如何判断 edit 控件 或 MEMO 控件 的 光标 在第几个字符上???????????????????? 急!!!!!!!!!!!!
- 请问我如何才能限制用户点击按钮的频率?
aStream:TMemoryStream;
begin
aStream:=TMemoryStream.Create;//创建对象
aStream.LoadFromFile('C:\我的文件.exe');//从文件读取内容。
//做一些事情。
aStream.Free;//释放对象
end;
var
sfile,dfile: file of byte;
ch:byte;
i,j:integer;
str:string;
begin
Assignfile(sfile,s);
Assignfile(dfile,d);
Reset(sfile);
ReWrite(dfile);
j:=0;
while not Eof(sfile) do
begin
read(sfile,ch);
str:=FormatHexToString(ch);
for i:=1 to length(str) do
begin
ch:=ord(str[i]);
write(dfile,ch);
end;
inc(j); // 换行
if j>15 then
begin
ch:=10;
write(dfile,ch);
ch:=13;
write(dfile,ch);
j:=0;
end;
end;
closefile(dfile);
closefile(sfile);
end;大家见笑了,希望对你有帮助
MyStream.Write(l, SizeOf(l));
MyStream.Write(s[1], l);
var
ms : TMemoryStream ;
ts : Tstream ;
fs : TFileStream ;
begin
ts := TMemoryStream.Create ;
ms := TStream.Create ;
fs := TFileStream ;
fname := 'C:\test' ;
ini := TIniFile.Create(fname+'\abcd.ini');
image1.Picture.Bitmap.SaveToStream(ts); ///如果是TS在这句就报抽象错(abstract error)
image1.Picture.Bitmap.SaveToStream(ms);
image1.Picture.Bitmap.SaveToStream(fs); ms.Position := 0 ;
fs.Position := 0 ;
ts.Position := 0 ; ini.WriteBinaryStream('Image','ImgContenMS',ms);///写不进INI文件,是空值
ini.WriteBinaryStream('Image','ImgContenFS',fs);///写不进INI文件,是空值
ini.WriteBinaryStream('Image','ImgContenTS',ts);
end;
大家看看,该怎么办哦?
关键是我只能写流。因为下次还要用这张图片。如果是读成STRING后写我就完成了