本文介绍了仅从浏览选项中提取文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在下面的代码中,显示文件的完整路径,这是仅显示"file-name.extension"的过程.
here in the below coding the full path of the file is displayed ,, ehat is the procedure to display only the "file-name.extension"
<pre lang="vb">Public Class Form1
Dim fdlg As OpenFileDialog = New OpenFileDialog()
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
fdlg.Title = "open"
fdlg.InitialDirectory = "c:\"
fdlg.Filter = "All files(*.*)|*.*|RTF files(*.rtf)|*.rtf|document files(*.doc)|*.doc"
fdlg.FilterIndex = 1
fdlg.RestoreDirectory = True
If fdlg.ShowDialog = Windows.Forms.DialogResult.OK Then
ListBox1.Items.Add(fdlg.FileName)
MessageBox.Show("You selected " & fdlg.FileName)
End If
End Sub
推荐答案
这篇关于仅从浏览选项中提取文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!