Results 1 to 11 of 11

Thread: {Resolved} - Killing images ... file disposal - access probs?

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2005
    Location
    UK
    Posts
    127

    {Resolved} - Killing images ... file disposal - access probs?

    i have this code below to remove dynamically created image boxes from a form and then kill the file and refresh the image list and repopulate image boxs but its not working .... keeps telling me that the files are open/readonly

    is there a quick way to close these images ?

    many thanks
    illskills

    VB Code:
    1. Dim sCurrFile As String
    2.         sCurrFile = cmbDesigns.Text
    3.         If sCurrFile.Trim = "" Then
    4.             Exit Sub
    5.         End If
    6.  
    7.         If MessageBox.Show("Remove from gallery?", "Remove image.", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) = DialogResult.OK Then
    8.             Dim i As Integer = 0
    9. removeanother:
    10.             For i = 0 To Me.Controls.Count - 1
    11.                 If Me.Controls(i).GetType.ToString = "System.Windows.Forms.PictureBox" Then
    12.                     If Me.Controls(i).Name <> "pbPreview1" Then
    13.                         If Me.Controls(i).Name <> "pbPrevTes" Then
    14.                             Dim oControl As PictureBox
    15.                             oControl = CType(Me.Controls(i), PictureBox)
    16.                             oControl.Image = Nothing
    17.                             Me.Controls.Remove(oControl)
    18.                             GoTo removeanother
    19.                         End If
    20.                     End If
    21.                 End If
    22.             Next i
    23.             pbPreview1.Image = Nothing
    24.             pbPrevTes.Image = Nothing
    25.  
    26.             On Error Resume Next
    27.             Kill(Application.StartupPath & "\Gallery\KeyPatterns\" & sCurrFile.Trim)
    28.             On Error GoTo 0
    29.  
    30.             Dim sFirstFile As String = ""
    31.             sFirstFile = PopulateItems()
    32.             cmbDesigns.Text = sFirstFile
    33.             If sFirstFile <> "" Then
    34.                 Dim oBMP As New Bitmap(Application.StartupPath & "\Gallery\KeyPatterns\" & Trim(sFirstFile))
    35.                 'oBMP = ResizeImage(oBMP, 320, 600)
    36.                 UpdateImage(oBMP)
    37.             End If
    38.         End If
    Last edited by illskills; Jan 1st, 2006 at 10:29 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width