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.");
}
        }
 
最大的網站源碼資源下載站,
新聞熱點
疑難解答
圖片精選