网站建设资讯

NEWS

网站建设资讯

vb.net获取文件名称 vb获取指定文件路径

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》获取文件夹下的所有MP3文件名的代码。

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

For Each FileName As String In IO.Directory.GetFiles("E:\音乐", "*.mp3")

TextBox1.Text = vbNewLine  IO.Path.GetFileName(FileName)

Next

End Sub

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中如何获取指定文件夹下的所有文件名?

VB可以使用FileListBox 控件来获取指定文件夹内的所有文件名。

FileListBox 控件,在运行时,在 Path 属性指定的目录中,FileListBox 控件将文件定位并列举出来。该控件用来显示所选择文件类型的文件列表。例如,可以在应用程序中创建对话框,通过它选择一个文件或者一组文件。

以下是组合使用DriveListBox 、控件DirListBox 控件和FileListBox 控件来获取硬盘下任何一个文件夹内的文件名。

Private Sub Dir1_Change()

File1.Path = Dir1.Path

End Sub

Private Sub Drive1_Change()

Dir1.Path = Drive1.Drive

End Sub

Private Sub File1_Click()

Dim i As Long

Debug.Print "目录夹内存在"  File1.ListCount  "个文件。"

End Sub


当前题目:vb.net获取文件名称 vb获取指定文件路径
新闻来源:http://cdweb.net/article/dospope.html