当前位置:编程学习 > C#/ASP.NET >>

openfiledialog 默认路径变成了"桌面"

我设置
.InitialDirectory = Trim(FRM.LBL.Text)
当LBL为空或者没有的路径是为什么 弹出的默认路径变成了桌面?之前一直是“我的文档”
同样在一个电脑上,另一个程序默认就会弹出“我的文档”


请问是怎么回事? --------------------编程问答-------------------- 你在可判断当 Trim(FRM.LBL.Text)=""时,让
openfiledialog.reset(),这样就初始化对话框了.
我也是新手,最近也是这么reset的,虽然不知道正误.
--------------------编程问答-------------------- 那如果路径不存在还要判断了? --------------------编程问答--------------------
引用 2 楼 envenlope 的回复:
那如果路径不存在还要判断了?


'判断文件夹
if System.IO.Directory.Exists("C:\Windows") then
   msgbox("文件夹C:\Windows存在!")
end if

'判断文件
if System.IO.File.Exists("C:\1.txt") then
   msgbox("文件夹C:\1.txt存在!")
end if
--------------------编程问答-------------------- 同样在一个电脑上,另一个程序默认就会弹出“我的文档”
--------------------编程问答-------------------- 你可以手动设置啊

if Trim(FRM.LBL.Text)="" and not System.IO.Directory.ExistsTrim(FRM.LBL.Text)) and not System.IO.File.ExistsTrim(FRM.LBL.Text))  then
openfiledialog1.InitialDirectory = "C:\"   '这里改成你想要的默认路径
end if

补充:.NET技术 ,  VB.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,