vb.net:
dim filename as string = "a.txt"
if filename <> "" then
dim path as string = server.mappath(filename)
dim file as system.io.fileinfo = new system.io.fileinfo(path)
if file.exists then
response.clear()
response.addheader("content-disposition", "attachment; filename=" + file.name)
response.addheader("content-length", file.length.tostring())
response.contenttype = "application/octet-stream"
response.filter.close()
response.writefile(file.fullname)
response.end()
else
response.write("this file does not exist.")
end if
end if
----------------------------------------------------------------
c#:
string filename = "a.txt";
if (filename != "")
{
string path = server.mappath(filename);
system.io.fileinfo file = new system.io.fileinfo(path);
if (file.exists)
{
response.clear();
response.addheader("content-disposition", "attachment; filename=" + file.name);
response.addheader("content-length", file.length.tostring());
response.contenttype = "application/octet-stream";
response.filter.close();
response.writefile(file.fullname);
response.end();
}
else
{
response.write("this file does not exist.");
}
}
最大的网站源码资源下载站,
新闻热点
疑难解答
图片精选