首页技术asp程序下载?asp 下载功能实现及调用

asp程序下载?asp 下载功能实现及调用

编程之家2023-11-01212次浏览

大家好,今天我将向大家分享有关asp程序下载和asp 下载功能实现及调用的一些独特见解,希望能够为你们带来新的思考和启示。

asp程序下载?asp 下载功能实现及调用

asp下载代码问题

可以的,你设置一个中转网页download.asp

然后以此种格式显示在网页上

<a rel="external nofollow" href="../download.asp?id=1834">金山快译</a>

在download.asp中这么设置:

<%

id=request("id")

asp程序下载?asp 下载功能实现及调用

'数据库中每个ID对应一个下载地址

'根据id找到下载地址,然后转到对应下载地址

response.redirect"http://127.0.0.1/1.exe"

%>

这样不仅可以实现自动生成中文名称,隐藏文件真实路径,再通过一些设置(如检查访问页的域名)来作防盗链设置

用ASP程序怎样调用迅雷自动下载资源

最近在写一个采集程序,需要下载目标站的附件,不过目标站文件下载速度很慢,于是想到能否调用迅雷来下载这个实现起来很容易,不过有一个问题,就是每添加个任务,迅雷的对话框就要弹出一次,很是不方便。我尝试了一下,去掉了对话框,方法如下:首先就是脚本了复制代码代码如下: Set ThunderAgent= CreateObject("ThunderAgent.Agent.1") Call ThunderAgent.AddTask(" http://www.itxuexi.com/iles/bjhyn.mp3","北京欢迎你.mp3","c:\a\",""," http://www.readlog.cn",1,0,5) Call ThunderAgent.CommitTasks2(1) Call ThunderAgent.AddTask(" http://file.fzone.cn/upload2/hompyFile/2007/28/921524670987.wma","放羊的星星.wma","c:\a\b\c\","", http://www.itxuexi.com,1,0,5) Call ThunderAgent.CommitTasks2(1) Set ThunderAgent= Nothing然后就是启动迅雷了,进入工具--配置--高级,把通过IE右键菜单“使用迅雷下载”添加任务这个选项前面的勾去掉。保持迅雷开启状态,这时候执行上面的脚本,就不会出现那个确认添加任务的对话框了。附:其中用到了AddTask这个方法,这个方法的参数如下:AddTask("下载地址","另存文件名","保存目录","任务注释","引用地址","开始模式","只从原始地址下载","从原始地址下载线程数")。参数名含义 pURL目标URL,必须参数 pFileName另存名称,默认为空,表示由迅雷处理,可选参数 pPath存储目录,默认为空,表示由迅雷处理,可选参数 pComments下载注释,默认为空,可选参数 pReferURL引用页URL,默认为空,可选参数 nStartMode开始模式,0手工开始,1立即开始,默认为-1,表示由迅雷处理,可选参数 nOnlyFromOrigin是否只从原始URL下载,1只从原始URL下载,0多资源下载,默认为0,可选参数 nOriginThreadCount原始地址下载线程数,范围1-10,默认为-1,表示由迅雷处理,可选参数

asp程序下载?asp 下载功能实现及调用

asp 下载功能实现及调用

ASP文件下载主要是头部的输出

'输出文件类型

'"application/force-download"这个是通用的,也可以根据文件类型使用其它如"image/jpeg"之类的

Response.AddHeader"Content-Type","application/force-download"

'输出文件名,保存文件时会在保存对话框下显示这个文件名。而不是你的asp文件名

Response.AddHeader"Content-Disposition","attachment; filename="&fName&";"

ASP存取数据库中的二进制数据使用AppendChunk和getChunk,

输出文件内容使用

Response.BinaryWrite文件内容(二进制格式)

不懂可以再问

怎样在asp.net中 实现多个文件打包下载

先下载 ICSharpCode.SharpZipLib.dll

public string cutStr="";

public void ZipFile(string FileToZip, string ZipedFile, int CompressionLevel, int BlockSize)

{

//如果文件没有找到则报错。

if(!System.IO.File.Exists(FileToZip))

{

throw new System.IO.FileNotFoundException("The specified file"+ FileToZip+" could not be found. Zipping aborderd");

}

System.IO.FileStream StreamToZip= new System.IO.FileStream(FileToZip, System.IO.FileMode.Open, System.IO.FileAccess.Read);

System.IO.FileStream ZipFile= System.IO.File.Create(ZipedFile);

ZipOutputStream ZipStream= new ZipOutputStream(ZipFile);

ZipEntry ZipEntry= new ZipEntry("ZippedFile");

ZipStream.PutNextEntry(ZipEntry);

ZipStream.SetLevel(CompressionLevel);

byte[] buffer= new byte[BlockSize];

System.Int32 size= StreamToZip.Read(buffer, 0, buffer.Length);

ZipStream.Write(buffer, 0, size);

try

{

while(size< StreamToZip.Length)

{

int sizeRead= StreamToZip.Read(buffer, 0, buffer.Length);

ZipStream.Write(buffer, 0, sizeRead);

size+= sizeRead;

}

}

catch(System.Exception ex)

{

throw ex;

}

ZipStream.Finish();

ZipStream.Close();

StreamToZip.Close();

}

//Get all DirectoryInfo

private void direct(DirectoryInfo di, ref ZipOutputStream s, Crc32 crc)

{

//DirectoryInfo di= new DirectoryInfo(filenames);

DirectoryInfo[] dirs= di.GetDirectories("*");

//遍历目录下面的所有的子目录

foreach(DirectoryInfo dirNext in dirs)

{

//将该目录下的所有文件添加到 ZipOutputStream s压缩流里面

FileInfo[] a= dirNext.GetFiles();

this.writeStream(ref s, a, crc);

//递归调用直到把所有的目录遍历完成

direct(dirNext, ref s, crc);

}

}

private void writeStream(ref ZipOutputStream s, FileInfo[] a, Crc32 crc)

{

foreach(FileInfo fi in a)

{

//string fifn= fi.FullName;

FileStream fs= fi.OpenRead();

byte[] buffer= new byte[fs.Length];

fs.Read(buffer, 0, buffer.Length);

//ZipEntry entry= new ZipEntry(file);

Path.GetFileName(file);

string file= fi.FullName;

file= file.Replace(cutStr,"");

ZipEntry entry= new ZipEntry(file);

entry.DateTime= DateTime.Now;

// set Size and the crc, because the information

// about the size and crc should be stored in the header

// if it is not set it is automatically written in the footer.

//(in this case size== crc==-1 in the header)

// Some ZIP programs have problems with zip files that don't store

// the size and crc in the header.

entry.Size= fs.Length;

fs.Close();

crc.Reset();

crc.Update(buffer);

entry.Crc= crc.Value;

s.PutNextEntry(entry);

s.Write(buffer, 0, buffer.Length);

}

}

///<summary>

///压缩指定目录下指定文件(包括子目录下的文件)

///</summary>

///<param name="zippath">args[0]为你要压缩的目录所在的路径

///例如:D:\\temp\\(注意temp后面加\\但是你写程序的时候怎么修改都可以)</param>

///<param name="zipfilename">args[1]为压缩后的文件名及其路径

///例如:D:\\temp.zip</param>

///<param name="fileFilter">文件过滤,例如*.xml,这样只压缩.xml文件.</param>

///

public bool ZipFileMain(string zippath, string zipfilename, string fileFilter)

{

try

{

//string filenames= Directory.GetFiles(args[0]);

Crc32 crc= new Crc32();

ZipOutputStream s= new ZipOutputStream(File.Create(zipfilename));

s.SetLevel(6);// 0- store only to 9- means best compression

DirectoryInfo di= new DirectoryInfo(zippath);

FileInfo[] a= di.GetFiles(fileFilter);

cutStr= zippath.Trim();

//压缩这个目录下的所有文件

writeStream(ref s, a, crc);

//压缩这个目录下子目录及其文件

direct(di, ref s, crc);

s.Finish();

s.Close();

}

catch

{

return false;

}

return true;

}

文章到此结束,如果本次分享的asp程序下载和asp 下载功能实现及调用的问题解决了您的问题,那么我们由衷的感到高兴!

建站系统(如何建立网站平台)快递查询源码?极兔快递单号怎么查询