【发布时间】:2015-07-27 18:13:36
【问题描述】:
我在 vb.net 2013 中做了一个程序。它在我的电脑 windows 7 上运行良好
当我在另一台计算机上设置程序时。一切正常,除了
当我尝试打开文件以选择图片时。单击打开按钮后,程序会冻结一分钟,然后抛出异常:
问题签名: 问题事件名称:BEX 应用程序名称:: BaldEagle.exe 应用程序版本:1.0.0.0 申请时间戳:55b3c11d 故障模块名称:StackHash_0a9e 故障模块版本:0.0.0.0 故障模块时间戳:00000000 异常偏移:c176c13f 异常代码:c0000005 异常数据:00000008 操作系统版本:6.1.7600.2.0.0.768.3 区域设置 ID:1033 附加信息 1 0a9e 附加信息 2 0a9e372d3b4ad19135b953a78882e789 附加信息 3 0a9e 附加信息 4 0a9e372d3b4ad19135b953a78882e789
互联网隐私政策: http://go.microsoft.com/fwlink/?linkid=104288&clcid=0x0401
打开文件选择图片的代码:
Dim ofd As New OpenFileDialog
ofd.Filter = "Text Files (*.jpg)|*.jpg|PNG(*.png)|*.png|gif(*.gif)|*.gif|JPEG(*.jpeg)|*.jpeg"
ofd.InitialDirectory = "c:\"
If ofd.ShowDialog = Windows.Forms.DialogResult.OK Then
Dim bmp As New Bitmap(ofd.FileName)
If bmp.Width.ToString = "300" And bmp.Height.ToString = "300" Then
' MsgBox("Cool")
Else
MsgBox("must be 300×300")
Exit Sub
End If
If Application.StartupPath & "\set\logo.png" = ofd.FileName Then
MsgBox("this is actually your ccurrent logo", MsgBoxStyle.Critical)
Exit Sub
End If
If MsgBox("do you want to change logo ?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
If My.Computer.FileSystem.FileExists(Application.StartupPath & "\set\logo.png") = True Then
My.Computer.FileSystem.DeleteFile(Application.StartupPath & "\set\logo.png")
End If
My.Computer.FileSystem.CopyFile(ofd.FileName, Application.StartupPath & "\set\logo.png")
End If
End If
【问题讨论】:
-
除了详细信息部分之外,还有一条实际的异常消息。如果我猜的话,我的第一个可能是您的应用程序无权删除或复制到可能是
Program Files的 StartupPath。此外,您可以更改位图的大小并将其制作为 300x300,而不是对用户大喊大叫。你还有很多东西没有被处理。 -
@Plutonix 谢谢。如果我希望我的程序删除或复制到启动,你能告诉我该怎么做吗?因为程序是以管理员身份运行的。是否还有其他方式以管理员身份运行它
标签: vb.net exception visual-studio-2013 openfiledialog