N
ndust
Unregistered / Unconfirmed
GUEST, unregistred user!
本人写了一个isapi的程序,生成一个excel临时文件,文件名随即,自动送回客户端,然后删除临时文件,
语句如下:
strname随机文件名,已经生成完毕.
mm:=TMemoryStream.Create;
mm.LoadFromFile(strname);
a.Connected:=false;
mm.Position:=0;
response.SetCustomHeader('Content-Disposition','attachment;filename=计划表.xls');
response.ContentType:='application/zip';
response.ContentStream:=mm;
response.SendResponse;
mm.Free;
if DeleteFile(strname) then
response.Content:='ok'+strname
else
response.Content:='NO'+strname;
文件不能删除.
改为:
mm:=TMemoryStream.Create;
mm.LoadFromFile(strname);
a.Connected:=false;
if DeleteFile(strname) then
response.Content:='ok'+strname
else
response.Content:='NO'+strname;
mm.Position:=0;
response.SetCustomHeader('Content-Disposition','attachment;filename=计划表.xls');
response.ContentType:='application/zip';
response.ContentStream:=mm;
response.SendResponse;
mm.Free;
就正常了.
哪位高手能解释原因,谢谢!
语句如下:
strname随机文件名,已经生成完毕.
mm:=TMemoryStream.Create;
mm.LoadFromFile(strname);
a.Connected:=false;
mm.Position:=0;
response.SetCustomHeader('Content-Disposition','attachment;filename=计划表.xls');
response.ContentType:='application/zip';
response.ContentStream:=mm;
response.SendResponse;
mm.Free;
if DeleteFile(strname) then
response.Content:='ok'+strname
else
response.Content:='NO'+strname;
文件不能删除.
改为:
mm:=TMemoryStream.Create;
mm.LoadFromFile(strname);
a.Connected:=false;
if DeleteFile(strname) then
response.Content:='ok'+strname
else
response.Content:='NO'+strname;
mm.Position:=0;
response.SetCustomHeader('Content-Disposition','attachment;filename=计划表.xls');
response.ContentType:='application/zip';
response.ContentStream:=mm;
response.SendResponse;
mm.Free;
就正常了.
哪位高手能解释原因,谢谢!