网站建设资讯

NEWS

网站建设资讯

vbnet选中文件 vb选择文件

VB.NET及可以选择文件夹,也可以选择文件的对话框

新建立个窗体,放入文件夹控件等,然后点确定返回一个字符串即可。

新泰网站制作公司哪家好,找创新互联!从网页设计、网站建设、微信开发、APP开发、响应式网站开发等网站项目制作,到程序开发,运营维护。创新互联于2013年开始到现在10年的时间,我们拥有了丰富的建站经验和运维经验,来保证我们的工作的顺利进行。专注于网站建设就选创新互联。

选择文件或者选择文件夹时,显示这个窗体,然后取这个字符串。

vb.net 如何打开listbox被选中文件夹

'在窗体启动时,给列表初始化,测试用,随便添加了几条列表项,并将列表的扩展多选功能打开。

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

ListBox1.Items.Add("c:\windows\notepad.exe")

ListBox1.Items.Add("c:\windows\system32\notepad.exe")

ListBox1.Items.Add("C:\WINDOWS\Web\Wallpaper\Bliss.bmp")

ListBox1.Items.Add("c:\windows\system32\drivers")

ListBox1.Items.Add("c:\dddddd")

ListBox1.Items.Add("c:\dos\2\3.txt")

ListBox1.SelectionMode = SelectionMode.MultiExtended

End Sub

'打开列表中所有选中的文件或者文件夹,并判断是否存在。

'如果是文件夹直接打开,如果是文件,打开目录后,并自动选中该文件

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

Dim i As Integer

Dim pr As Process = New Process

Dim curFile As String

For i = 0 To ListBox1.SelectedItems.Count - 1

pr.StartInfo.FileName = "explorer.exe"

curFile = ListBox1.SelectedItems(i)

If System.IO.Directory.Exists(curFile) Then

pr.StartInfo.Arguments = Chr(34) curFile Chr(34)

Else

If System.IO.File.Exists(curFile) Then

pr.StartInfo.Arguments = "/n,/select," Chr(34) ListBox1.SelectedItems(i) Chr(34)

Else

Continue For

End If

End If

pr.Start()

Next

pr = Nothing

End Sub

vb.net中,如何点击按钮调出选择文件窗口选中图片并在picturebox中显示出来?

button , OpenFileDialog , PictureBox , textbox 控件,我把图片显示在 picturebox 中,而路

径存放在 textbox 中,不知道这样行不行。

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

Dim filename As String

OpenFileDialog1.Filter = "jpg files (*.jpg)|*.jpg"

OpenFileDialog1.FilterIndex = 1

If OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then

filename = OpenFileDialog1.FileName

Else

End

End If

If Not (PictureBox1.Image Is Nothing) Then

PictureBox1.Image.Dispose()

PictureBox1.Image = Nothing

End If

'PictureBox1.Image = System.Drawing.Image.FromFile(filename)

去掉注释后就显示图片

TextBox1.Text = filename

End Sub

picturebox中只记录文件存放的路径,我找了一个 ImageLocation 函数

PictureBox1.ImageLocation = filename 不过还是会显示图片

vb.net 如何实现文件选择

给你一个遍历所有盘符下的文件夹的例子

加一个遍历文件的就可以了。

TreeNode node = new TreeNode("我的电脑");

treeView.Nodes.Add(node); //加入一个我的电脑节点

string[] drivesName = System.IO.Directory.GetLogicalDrives() //取得驱动器列表的集合

foreach(string name in drivesName) //用foreach遍历集合

{

TreeNode drivesNode = new TreeNode(name);

node.Nodes.Add(drivesNode); //加到我的电脑节点下


分享文章:vbnet选中文件 vb选择文件
当前路径:http://cdweb.net/article/dosejoh.html