再次提这个问题,关于相对路径的...

来源:百度知道 编辑:UC知道 时间:2024/06/18 05:00:17
AA = iif(right(app.path,1) <> "\" and right(app.path,1) <> "/",app.path & "/",app.path ) & "\音乐\bs.mp3" 这对于二级目录是判断过的 好象这段代码有几个版本,到底哪个是对的:
版本1:AA = iif(right(app.path,1) <> "\" and right(app.path,1) <> "/",app.path & "/",app.path ) & "\音乐\bs.mp3"

版本2:AA = iif(right(app.path,1) <> "\" and right(app.path,1) <> "/",app.path & "\",app.path ) & "\音乐\bs.mp3"

版本3:AA = iif(right(app.path,1) <> "\" and right(app.path,1) <> "/",app.path & "\",app.path ) & "音乐\bs.mp3"

版本4:AA = iif(right(app.path,1) <> "\" and right(app.path,1) <> "/",app.path & "/",app.path ) & "音乐\bs.mp3"

还有一个版本是:将上面and部分改成or....

另外我在测试的时候发现,到二级目录可以播放音乐,怎么放

我晕死 iif判断的作用就是为了无论任何情况都确保输出的当前程序所在目录路径的最后是一个 \

你后边的字符串还加个\开头
你还这样 "\音乐\bs.mp3"
不成了如这样的吗?

C:\abc\\音乐\bs.mp3 ?? 你说对吗?

版本3:AA = iif(right(app.path,1) <> "\" and right(app.path,1) <> "/",app.path & "\",app.path ) & "音乐\bs.mp3"

这是对的

你调试代码试下,用msgbox AA看看文件路径是不是你要的

没错..program files属于系统的一个安全目录...一般所以的软件都是安装在这个目录..WINDOWS为了安全性..所以中间多了一个空格..所以很多时候读取这个目录都会出问题的..