Application.StartupPath

来源:互联网 发布:手机信号干扰软件 编辑:程序博客网 时间:2024/06/06 19:48

 string Path = Application.StartupPath.Substring(0, Application.StartupPath.Substring(0,

Application.StartupPath.LastIndexOf("\\")).LastIndexOf("\\"));


Substring(index,length)       index  表示开始截取位置;length表示截取长度;

LastIndexOf(“\\”)  表示最后一个\\ 出现的位置也就是index,是int类型的。

Application.StartupPath是一个只读属性,是不可以设置的。
Application.StarupPath获取启动了应用程序的可执行文件的路径,不包括可执行文件的
名称

Path+=@"\01.jpg";  等价于Path+="\\01.jpg";
一般后面接一段字符串,比如路径,可以减少很多不必要的转义等,比如"c:\\1.txt"
@"c:\1.txt"

阅读全文
0 0
原创粉丝点击