新网创想网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

vb.net取文件路径 vb打开文件路径

在VB.NET中如何取得当前目录的路径?

命名空间:System.Windows.Forms

克什克腾ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为创新互联公司的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:18982081108(备注:SSL证书合作)期待与您的合作!

Application.StartupPath 属性(返回String)

获取启动了应用程序的可执行文件的路径,不包括可执行文件的名称。

Application.ExecutablePath 属性(返回String)

获取启动了应用程序的可执行文件的路径,包括可执行文件的名称。

如何实现VB.NET获取程序运行路径

System.Environment.CurrentDirectory

这才是vb.net的获取程序运行路径的方法

关于在vb.net中获取文件路径的问题,如何解决?

当然不能~! Me.OpenFileDialog1. FileNames这个是多选文件时,一个文件数组, 不是单个文件,单个文件用Me. OpenFileDialog1.FileName 而Str(Me.OpenFileDialog1. FileNames) 又是什么意思呢~?把数组转化成字符串~?~~?~? strFileDirectary = Me.OpenFileDialog1.FileName 这样strFileDirectary 得到的是完整的文件路径,不是文件夹 我搞不懂你到底要获得文件路径还是文件所在的文件夹~~?~?

希望采纳

vb.net 有个文件路径C:\Users\New York\SoHo\abc.doc,我想从这个路径中提取出SoHo\abc.doc如何实现?

' The file system path we need to split

Dim s As String = "C:\Users\New York\SoHo\abc.doc"

' Split the string on the backslash character

Dim parts As String() = s.Split(New Char() {"\"c})

之后取数组的最后两个 用“\”连接起来就可以了。

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

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

下面提供个下载的静态方法,是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取文件路径 vb打开文件路径
网站URL:http://www.wjwzjz.com/article/hpdpsj.html
在线咨询
服务热线
服务热线:028-86922220
TOP