编程论坛
注册
登录
编程论坛
→
VB.NET论坛
新手求教如何获取程序运行所在的文件夹
cokoed4
发布于 2015-10-15 23:21, 1933 次点击
用Application.StartupPath 获取的是程序所在的debug的路径,,例如D:\aaa\bbb\ccc\bin\debug
但我只想获取程序所在的aaa的路径 也就是要D:\aaa\
请问语句怎么写呢?高手指教下
1 回复
#2
cokoed4
2015-10-15 23:56
Dim strPath As String = Application.StartupPath.ToString()
Dim strDirTemp As String()
strDirTemp = strPath.Split("\")
strPath = String.Empty
For i As Integer = 0 To strDirTemp.Length - 3
strPath += strDirTemp(i) & "\"
Next
自己解决了
1