奇怪的下载问题! [英] Strange download problem!

查看:67
本文介绍了奇怪的下载问题!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!每个人,


我正面临一个非常奇怪的下载问题。我使用以下代码来

将XML文件下载到客户端:


带响应

''clear buffer

调用.Clear()


''指定可下载文件的类型

.ContentType =" application / octet-stream" ; ''我有

也尝试将此语句更改为Response.ContentType =" Text / XML"

,但结果相同

''在FileDownload对话框中删除默认文件名

调用.AddHeader(" Content-Disposition"," attachment;

filename =" ;"Download.XML"")


''强制刷新缓冲区

调用.Flush()

''下载文件

Call .WriteFile(" Original.XML")

结束


下载完成后,我发现一些HTML代码附加到

下载文件中原始XML语句的末尾。 HTML代码是

下载之前的格式。我想知道是什么导致了这个结果和解决方案。当然,我只需要XML内容。


感谢您的关注和友好的建议!


问候,

James

Hi! everybody,

I''m facing a quite strange download problem. I use the following code to
download an XML file to client side:

With Response
'' clear buffer
Call .Clear()

'' specify the type of the downloadable file
.ContentType = "application/octet-stream" '' I have
also tried to change this statement to Response.ContentType = "Text/XML"
, but the result is same

'' det the default filename in the FileDownload dialog box
Call .AddHeader("Content-Disposition", "attachment;
filename=""Download.XML""")

'' force to flush buffer
Call .Flush()

'' download the file
Call .WriteFile("Original.XML")
End With

When the download is finished, I found that some HTML code are attached to
the end of my original XML statements in download file. The HTML code is
what exact the form just before download. I would like to know what causes
this result and the solution. Certainly, I need the XML content only.

Thanks for your attention and kindly advice!

Regards,
James

推荐答案

一个建议,尝试使用Response.Write(文件)而不是writefile,这可能会治愈

这种疾病。


-

-----------

有TidBits吗?

在此处获取: www.networkip.net/tidbits

" James Wong" < CP ***** @ commercialpress.com.hk.NO_SPAM>在消息中写道

新闻:ez ************** @ TK2MSFTNGP09.phx.gbl ...
One suggestion, try Response.Write(file) instead of writefile, that may cure
the ailment.

--
-----------
Got TidBits?
Get it here: www.networkip.net/tidbits
"James Wong" <cp*****@commercialpress.com.hk.NO_SPAM> wrote in message
news:ez**************@TK2MSFTNGP09.phx.gbl...
嗨!大家好,

我正面临一个非常奇怪的下载问题。我使用以下代码将XML文件下载到客户端:

响应
''清除缓冲区
调用.Clear()

''指定可下载文件的类型
.ContentType =" application / octet-stream" ''我有
也尝试将此语句更改为Response.ContentType =" Text / XML"
,但结果相同

''删除默认文件名FileDownload对话框
调用.AddHeader(" Content-Disposition"," attachment;
filename ="" Download.XML""")

''强制刷新缓冲区
调用.Flush()
''下载文件
调用.WriteFile(" Original.XML")
结束<下载完成后,我发现一些HTML代码附加到下载文件中原始XML语句的末尾。 HTML代码与下载之前的格式完全相同。我想知道
导致这个结果和解决方案。当然,我只需要XML内容。

感谢您的关注和友好的建议!

问候,
James
Hi! everybody,

I''m facing a quite strange download problem. I use the following code to
download an XML file to client side:

With Response
'' clear buffer
Call .Clear()

'' specify the type of the downloadable file
.ContentType = "application/octet-stream" '' I have
also tried to change this statement to Response.ContentType = "Text/XML"
, but the result is same

'' det the default filename in the FileDownload dialog box
Call .AddHeader("Content-Disposition", "attachment;
filename=""Download.XML""")

'' force to flush buffer
Call .Flush()

'' download the file
Call .WriteFile("Original.XML")
End With

When the download is finished, I found that some HTML code are attached to
the end of my original XML statements in download file. The HTML code is
what exact the form just before download. I would like to know what causes this result and the solution. Certainly, I need the XML content only.

Thanks for your attention and kindly advice!

Regards,
James



Alvin,


感谢您的回复。但即使我将其更改为Response.Write,

奇怪的行为仍然存在。


问候,

James


" Alvin Bruney" < vapordan_spam_me_not@hotmail_no_spamhotmail.com> | b?l¥ó

新闻:eb ************** @TK2MSFTNGP10.phx.gbl¤¤??? g ...
Alvin,

Thanks for your response. But even I change it to Response.Write, the
strange behavior still be there.

Regards,
James

"Alvin Bruney" <vapordan_spam_me_not@hotmail_no_spamhotmail.com > |b?l¥ó
news:eb**************@TK2MSFTNGP10.phx.gbl ¤¤???g...
一个建议,尝试使用Response.Write(文件)而不是writefile,这可能是
治愈疾病。
One suggestion, try Response.Write(file) instead of writefile, that may cure the ailment.



Hello James,


感谢您在小组中发帖。


请尝试在结束时之前添加Call.End()看看它是否有效。


我使用了以下代码,它对我很有用:


string filename =" C:\\ \\ MyFolder\MyFile.xml" ;;

System.IO.FileInfo file = new System.IO.FileInfo(fileName);

Response.Clear(); //清除缓冲区中的当前输出内容

Response.AppendHeader(" Content-Disposition"," attachment; filename =" +

file.Name) ;

Response.AppendHeader(" Content-Length",file.Length.ToString());

Response.ContentType =" application / octet-stream" ;;

Response.WriteFile(file.FullName);

Response.End();


这会回答你的问题吗?如果问题仍然存在,请感觉

免费在这里发布。


祝你好运,

Yanhong Huang
Microsoft在线合作伙伴支持


安全! - www.microsoft.com/security

发布是按原样提供的。没有保证,也没有授予任何权利。

Hello James,

Thanks for posting in the group.

Please try adding Call.End() before "End With" to see if it works.

I used the following code and it works great for me:

string filename = "C:\MyFolder\MyFile.xml";
System.IO.FileInfo file = new System.IO.FileInfo(fileName);
Response.Clear(); // clear the current output content from the buffer
Response.AppendHeader("Content-Disposition", "attachment; filename=" +
file.Name);
Response.AppendHeader("Content-Length", file.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.WriteFile(file.FullName);
Response.End();

Does that answer your question? If the problem is still there, please feel
free to post here.

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! ¨C www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.


这篇关于奇怪的下载问题!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆