vb.net从文件路径中获取文件名获取方法,参考实例如下:
'获取路径名各部分:
如:
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
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
Then
GetFileExtName
".txt"
Else
GetFileExtName
Mid(FilePathFileName,
J,
i)
End
If
End
Function
VB.NET获取目录文件夹名称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
vb.net 获取目录下文件夹名不包括隐藏文件夹Vb.net获取某个目录下文件夹名称(不包含隐藏文件夹)实现代码如下vb.net文件夹名:
Dim dir As New DirectoryInfo("D:\")
For Each d As DirectoryInfo In dir.GetDirectories
ComboBox1.Items.Add(d.Name)
Next
dim finfo as new fileinfo(d.name)
if (finfo.attributes and FileAttributes.Hidden)FileAttributes.Hidden then
ComboBox1.Items.Add(d.Name)
end if
【vb.net文件夹名 vbnet打开文件路径】vb.net文件夹名的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于vbnet打开文件路径、vb.net文件夹名的信息别忘了在本站进行查找喔 。
推荐阅读
- word怎么排数字,word中数字排列
- flutter使用siri,flutter调用jni
- 写实风格即时战略游戏,写实的战争游戏
- php用ajax处理数据 ajax获取php数据
- 安卓电视怎么安装蓝牙功能,安卓手机怎么连接电视蓝牙
- 微信登录电脑怎么登录不上,微信登录电脑登不上怎么回事
- 无人雪糕车直播,成品雪糕无人售货机
- php打开文件写入数据 php写入文件内容
- go语言读静态配置文件,go语言读取配置文件