如何在vb6中确定文件或目录的路径?
我正在做一个项目,我需要从用户那里得到一条路径,并在这条路径上做一些事情,但我需要知道这条路径是什么。我无法通过检查分机来实现这一点。因为可能一个文件没有扩展名。php中是否有类似于如何在vb6中确定文件或目录的路径?,vb6,filesystems,Vb6,Filesystems,我正在做一个项目,我需要从用户那里得到一条路径,并在这条路径上做一些事情,但我需要知道这条路径是什么。我无法通过检查分机来实现这一点。因为可能一个文件没有扩展名。php中是否有类似于Is_dir()&Is_file()函数的函数?检查原始字符串是否也是有效字符串 Function FileOrFolder(strg As String) Dim fs, FExists, DirExists Set fs = CreateObject("Scripting.FileSystemObject
Is_dir()
&Is_file()
函数的函数?检查原始字符串是否也是有效字符串
Function FileOrFolder(strg As String)
Dim fs, FExists, DirExists
Set fs = CreateObject("Scripting.FileSystemObject")
FExists = fs.FileExists(strg)
DirExists = fs.folderexists(strg)
If FExists = True Then
FileOrFolder = "It's a file" '// file
ElseIf DirExists = True Then
FileOrFolder = "It's a folder" '// folder
Else
FileOrFolder = "Neither a file nor a folder" '// user string invalid
End If
End Function
你考虑过显而易见的事情吗
If GetAttr(Path) And vbDirectory Then
MsgBox "Directory"
Else
MsgBox "Not directory"
End If
还有一个要使用的函数:
Dir$()
使用默认的vbNormal
attributes参数Dir$()
时,如果pathname参数是目录,则返回空字符串
Private Sub Command1_Click()
Dim strPath As String
Dim strFile As String
strPath = "c:\temp"
strFile = "c:\temp\pic.bmp"
Print strPath & " : " & CStr(IsDir(strPath))
Print strFile & " : " & CStr(IsDir(strFile))
End Sub
Private Function IsDir(strPath As String) As Boolean
If Len(Dir$(strPath, vbNormal)) = 0 Then
IsDir = True
Else
IsDir = False
End If
End Function
io.file.exists()和io.directory.exists()是否需要添加引用?VB6或VB.NET?它对VB6当然很重要。我可以在VB.NETPlus one中处理它。值得一提的是,如果路径不存在,它将引发错误。
(GetAttr(Path)和vbDirectory)0
更为明确