注册 登录
编程论坛 VB6论坛

求助,怎么把相对路径 的绝对路径字符提取出来!

suzhanpeng 发布于 2017-12-22 21:39, 2660 次点击
怎么把相对路径 的绝对路径字符提取出来!
例如:App.Path & "\123.txt" 的绝对路径 "D:\123.txt" 提取出来
3 回复
#2
ZHRXJR2017-12-23 08:12
Dim SS As String
SS = App.Path & "\123.txt"
Label1.Caption = SS
SS就是绝对路径了,这么的问题自己不动动手,你能够学进去吗?
#3
wds12017-12-23 09:01
App.Path & "\123.txt" 表示当前程序目录下的123.txt
如果你想把当前目录文件保存到当前程序的根目录可以如下实现
temp = App.Path & "\123.txt"
msgbox Right(temp, Len(temp) - InStrRev(temp, "\") + 1)'取得\123.txt
msgbox Left(temp, 2)'取得D:【当前盘符】
msgbox temp2 & temp1

也可以连着写
temp = App.Path & "\123.txt"
msgbox Left(temp, 2) & Right(temp, Len(temp) - InStrRev(temp, "\") + 1)'D:\123.txt



[此贴子已经被作者于2017-12-23 09:14编辑过]

#4
suzhanpeng2017-12-23 17:10
回复 2楼 ZHRXJR
建议不错
Dim F7 As String, nStr7 As String, nSize7 As Long, S7 As Long
   F7 = App.Path & "\config.ini"
   nSize7 = 255: nStr7 = String(nSize7, 0)
   d7 = GetPrivateProfileString("Form2", "CLpart", vbNullString, nStr7, nSize7, F7)
   S7 = InStr(nStr7, Chr(0))
   If S7 > 0 Then
   nStr7 = Left(nStr7, S7 - 1)  'nStr7在这里提取的字符串是 “ App.Path & "\材质库.sldmat"”
   End If
boolstatus = swApp.SetUserPreferenceStringValue(swUserPreferenceStringValue_e.swFileLocationsMaterialDatabases, nStr7)   '这里nStr7 还是认为了相对路径的字符串,没有变成绝对路径的字符串。

改了一下变成
Label1.Caption=nStr7
boolstatus = swApp.SetUserPreferenceStringValue(swUserPreferenceStringValue_e.swFileLocationsMaterialDatabases, Label1.Caption)  ’OK!!
1