01
Function
FPath$(nhwnd&,
Title$)
02
Dim
bi
As
BROWSEINFO
03
Dim
idl
As
ITEMIDLIST
04
Dim
rtn&,
pidl&,
path$,
pos%
05
bi.hOwner
=
nhwnd&
06
bi.pidlRoot
=
idl.mkid.cb
07
bi.lpszTitle
=
Title$
08
bi.ulFlags
=
&H1
09
pidl&
=
SHBrowseForFolder(bi)
10
path$
=
Space$(512)
11
rtn&
=
SHGetPathFromIDList(ByVal
pidl&,
ByVal
path$)
12
pos%
=
InStr(path$,
Chr$(0))
13
FPath$
=
Left(path$,
pos
-
1)
14
End
Function
private void 打开文件对话框按钮_Click(object sender, EventArgs e)//按钮事件{
OpenFileDialog op = new OpenFileDialog() //实例一个文件对话框
op.Title = "选择文件" //文件标题
op.Filter = "jpg文件|*.jpg|jepg文件|*.jepg|bmp文件|*.bmp|所有文件|*.*"//文件类型
op.Multiselect = false //是否允许选择多项文件
op.InitialDirectory = "D:\\我的文档" //初始文件夹
if (op.ShowDialog() == DialogResult.OK) //如果以选择了文件
{
pictureBox1.Image = Image.FromFile(op .FileName) //显示图片在图片框
}
op.Dispose()//释放打开文件对话框
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)