RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
vb.net下载文件 vbnet fileget

vb.net怎么实现点击下载,获取文件路径并下载

下载,直接通过url读取文件,然后Response.OutputStream.Write()数据

成都创新互联-专业网站定制、快速模板网站建设、高性价比平顶山网站开发、企业建站全套包干低至880元,成熟完善的模板库,直接使用。一站式平顶山网站制作公司更省心,省钱,快速模板网站建设找我们,业务覆盖平顶山地区。费用合理售后完善,10余年实体公司更值得信赖。

下面提供个下载的静态方法,是C#的,供参考:

/// summary

/// 下载文件

/// /summary

/// param name="fileName"下载的文件名称(包括扩展名)/param

/// param name="filePath"下载文件的绝对路径/param

public static void DownFile(string fileName, string filePath)

{

//打开要下载的文件,并把该文件存放在FileStream中                

System.IO.FileStream Reader = System.IO.File.OpenRead(filePath);

//文件传送的剩余字节数:初始值为文件的总大小                

long Length = Reader.Length;

HttpContext.Current.Response.Buffer = false;

HttpContext.Current.Response.AddHeader("Connection", "Keep-Alive");

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

HttpContext.Current.Response.Charset = "utf-8";

HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode(fileName));

HttpContext.Current.Response.AddHeader("Content-Length", Length.ToString());

byte[] Buffer = new Byte[10000];//存放欲发送数据的缓冲区                

int ByteToRead; //每次实际读取的字节数               

while (Length  0)

{    

//剩余字节数不为零,继续传送                    

if (HttpContext.Current.Response.IsClientConnected)

{    

//客户端浏览器还打开着,继续传送                        

ByteToRead = Reader.Read(Buffer, 0, 10000);                   //往缓冲区读入数据                        

HttpContext.Current.Response.OutputStream.Write(Buffer, 0, ByteToRead);    

//把缓冲区的数据写入客户端浏览器                        

HttpContext.Current.Response.Flush(); //立即写入客户端                        

Length -= ByteToRead;//剩余字节数减少                            }

else

{                         

//客户端浏览器已经断开,阻止继续循环                        

Length = -1;

}

}                //关闭该文件               

Reader.Close();

}

QQ:121一九五五121

VB.NET如何实现文件的下载

给你一个遍历所有盘符下的文件夹的例子加一个遍历文件的就可以了。TreeNode node = new TreeNode("我的电脑"); treeView.Nodes.Add(node); //加入一个我的电脑节点 string[] drivesName = System.IO.Directory.GetLogicalDrives() //取得驱动器列表的集合 foreach(string name in drivesName) //用foreach遍历集合 { TreeNode drivesNode = new TreeNode(name); node.Nodes.Add(drivesNode); //加到我的电脑节点下 }

vb.net下载文件

下载文件的话你要到这个名称空间找都这个函数

System.Net.WebClient.DownloadData(ByVal

String)

As

Byte(

)

--下载资源

DownloadData:

Public

Function

DownloadData(ByVal

address

As

String)

As

Byte(

)

System.Net.WebClient

的成员

摘要:

System.Byte

数组形式通过指定的

URI

下载资源。

参数:

address:

从中下载数据的

URI。

返回值:

一个

System.Byte

数组,其中包含下载的资源。

异常:

System.Net.WebException:

通过组合

System.Net.WebClient.BaseAddress

address

所构成的

URI

无效。-

-

下载数据时发生错误。

System.NotSupportedException:

该方法已在多个线程上同时调用。

System.Net.WebClient.DownloadFile(ByVal

String,

ByVal

String)

--下载文件

DownloadFile:

Public

Sub

DownloadFile(ByVal

address

As

String,

ByVal

fileName

As

String)

System.Net.WebClient

的成员

摘要:

将具有指定

URI

的资源下载到本地文件。

参数:

address:

从中下载数据的

URI。

fileName:

要接收数据的本地文件的名称。

异常:

System.Net.WebException:

通过组合

System.Net.WebClient.BaseAddress

address

所构成的

URI

无效。-

-

filename

null

System.String.Empty。-

-文件不存在。-

-

下载数据时发生错误。

System.NotSupportedException:

该方法已在多个线程上同时调用。


文章题目:vb.net下载文件 vbnet fileget
标题网址:http://scyingshan.cn/article/dogpojh.html