大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
获取方法,参考实例如下:
创新互联建站从2013年成立,先为温州等服务建站,温州等地企业,进行企业商务咨询服务。为温州企业网站制作PC+手机+微官网三网同步一站式服务解决您的所有建站问题。
'获取路径名各部分: 如: c:\dir1001\aaa.txt
'获取路径路径 c:\dir1001\
Public Function GetFileName(FilePathFileName As String) As String '获取文件名 aaa.txt
On Error Resume Next
Dim i As Integer, J As Integer
i Len(FilePathFileName)
J InStrRev(FilePathFileName, "\")
GetFileName Mid(FilePathFileName, J + 1, i)
End Function
''获取路径路径 c:\dir1001\
Public Function GetFilePath(FilePathFileName As String) As String '获取路径路径 c:\dir1001\
On Error Resume Next
Dim J As Integer
J InStrRev(FilePathFileName, "\")
GetFilePath Mid(FilePathFileName, 1, J)
End Function
'获取文件名但不包括扩展名 aaa
Public Function GetFileNameNoExt(FilePathFileName As String) As String '获取文件名但不包括扩展名 aaa
On Error Resume Next
Dim i As Integer, J As Integer, k As Integer
i Len(FilePathFileName)
J InStrRev(FilePathFileName, "\")
k InStrRev(FilePathFileName, ".")
If k 0 Then
GetFileNameNoExt Mid(FilePathFileName, J + 1, i - J)
Else
GetFileNameNoExt Mid(FilePathFileName, J + 1, k - J - 1)
End If
End Function
'===== '获取扩展名 .txt
Public Function GetFileExtName(FilePathFileName As String) As String '获取扩展名 .txt
On Error Resume Next
Dim i As Integer, J As Integer
i Len(FilePathFileName)
J InStrRev(FilePathFileName, ".")
If J 0 Then
GetFileExtName ".txt"
Else
GetFileExtName Mid(FilePathFileName, J, i)
End If
End Function
function Newfile as fileinfo
Dim dic As New System.IO.DirectoryInfo("C:\Users\Q\Desktop\数据")
Dim files = dic.GetFiles.OrderByDescending(Function(s) s.CreationTime)
if files.
return files.first
end function
注意引入 system.linq
Dim
dir
As
New
IO.DirectoryInfo("C:\TDDownload")
//
目录下就一个文件夹
If
dir.GetDirectories.Length
Then
MessageBox.Show(dir.GetDirectories.GetValue(0).ToString())
End
If
//
目录下多个文件夹
'For
Each
d
As
IO.DirectoryInfo
In
dir.GetDirectories
'
MessageBox.Show(d.FullName)
'Next
按照指定的完整路径,循环搜索其中文件夹,搜索到一个,就保存到字符串变量,搜索到新的覆盖该变量,一直到循环结束,输出该变量的值。