我想只从完全限定的名称中选择一个路径.
例如,C:\Newfolder\iTDC.mdb显示在文本框中.
但我只想采取C:\Newfolder,删除iTDC.mdb.
怎么可以跳过文件?
又脏又脏
Dim sPath As String
sPath = "C:\Newfolder\iTDC.mdb"
sPath = Left(sPath, InStrRev(sPath, "\"))
Run Code Online (Sandbox Code Playgroud)
如果添加对Microsoft Scripting Runtime的引用(使用Project-> References),则可以使用与FileSystemObject文件相关的操作.例如:
Dim oFSO as New FileSystemObject
strFolder = oFSO.GetFolder(strPath)
Run Code Online (Sandbox Code Playgroud)
在FileSystemObject还具有用于构成路径(其他有用的方法BuildPath)和用于测试文件,文件夹等的存在(FileExists,FolderExists).