我通過下面的代碼該進程無法訪問該文件
Dim WithEvents Pedit As DevExpress.XtraEditors.PictureEdit
Private Sub LoadImagesCommon(ByVal fi As FileInfo)
Pedit = New DevExpress.XtraEditors.PictureEdit
Pedit.Width = 133
Pedit.Height = 98
Pedit.Image = Image.FromFile(fi.FullName)
Pedit.Properties.SizeMode = DevExpress.XtraEditors.Controls.PictureSizeMode.Zoom
Pedit.ToolTip = fi.Name
AddHandler Pedit.MouseClick, AddressOf Pedit_MouseClick
AddHandler Pedit.MouseEnter, AddressOf Pedit_MouseEnter
AddHandler Pedit.MouseLeave, AddressOf Pedit_MouseLeave
FlowLayoutPanel1.Controls.Add(Pedit)
End Sub
問題將圖像添加到FlowLayoutPanel的控制是,我得到以下錯誤The process cannot access the file xxxx because it is being used by another process.
當我嘗試刪除我在前一步加載的圖像。
FlowLayoutPanel1.Controls.Clear()
FlowLayoutPanel1.Refresh()
For Each fi As FileInfo In New DirectoryInfo(My.Settings.TempDirectory).GetFiles
RemoveHandler Pedit.MouseClick, AddressOf Pedit_MouseClick
RemoveHandler Pedit.MouseEnter, AddressOf Pedit_MouseEnter
RemoveHandler Pedit.MouseLeave, AddressOf Pedit_MouseLeave
File.Delete(fi.FullName)
Next
那麼我在這裏做錯了什麼?
您的解決方案(映像文件的完整路徑名)比我的好。 – 2010-10-24 20:11:05
我相信正好相反。請看看更新。 – OrElse 2010-10-25 06:52:33