启动画面仍然使用背景图像如何发布vb.net

时间:2015-12-18 11:34:41

标签: vb.net image dispose

我正在将所有图像从服务器复制到本地工作站,以便无法篡改它们,当应用程序关闭时,我想删除这些文件。

目前我刚刚使用启动画面背景图像进行了测试。我将文件复制到工作站的临时文件夹中,效果很好。

但是当我尝试删除它时,我无法这样做,因为它仍然被启动画面使用。

如何从启动画面释放它?

我试图删除目录

我在启动画面加载方法中使用图像,代码如下:

My.Computer.FileSystem.CopyDirectory("\\bwingssrv01\NRSRoot$\NRS_img", "c:\windows\temp\NRS_img", True)
Me.BackgroundImage = Image.FromFile("c:\windows\temp\NRS_img\splash.jpg")

我试图删除MyApplication_Shutdown上的目录

1 个答案:

答案 0 :(得分:-1)

我能够通过在SplashScreen中使用委托来解决这个问题:

我只是尝试将背景图像放置在我的代码末尾的My MDI表单中调用的函数中,并且成功了。

我使用以下代码来解决问题:

我的SplashScreen中的代表:

Public Delegate Sub unload()

并在我的SplashScreen中执行以下功能:

Public Sub unload1()
    If Me.InvokeRequired Then
        Me.Invoke(New unload(AddressOf unload1))
    Else
        Me.Visible = False 'to avoid showing the error image in background
        Me.BackgroundImage.Dispose()
    End If
End Sub

在我的MDI表格结尾处,我使用了以下内容:

SplashScreen1.unload1()
Threading.Thread.Sleep(100)