Results 1 to 2 of 2

Thread: File Renaming

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2001
    Location
    INDIA
    Posts
    31

    Thumbs up File Renaming

    HI all,

    VB.NET
    ---------
    I am displaying the images in a "Picture Box" one by one, and the user can add the selected images to the listbox.

    From the ListBox i am trying to Rename the "Selected File" from the Listbox and upload it to the server using FTP.

    When i am trying to Rename the file it is giving an error saying "The file filename.jpg is being used by another process" whereas the file i am not using in any application.

    Please give me the solution.

    Thanks in advance.

    Regards

    Nag K.
    Nagendra K

  2. #2
    New Member
    Join Date
    Jun 2004
    Posts
    3
    What's the code you're using to upload the images to the picture box? I've been doing quite a lot of image management lately, although not with FTP.

    Just off the top of my head, if you're using a Stream of some kind to grab the image then make sure that after the image is uploaded you close the stream object and any readers you're using.

    The cause for the "file is being used by another process" type error with me is typically due to a stream object still being open.

    Good luck,
    Daniel Gow

    Here's how I usually grab images...

    Code:
         Public Function ReturnImage(ByVal image_path) As Image
            Dim fso As IO.FileStream
            Dim img As Drawing.Bitmap
            Try
                fso = New IO.FileStream(image_path, IO.FileMode.Open)
                img = New Drawing.Bitmap(fso)
    
                fso.Close()
    
                Return img
            Catch ex As Exception
                Err(ex)
            End Try
        End Function
    So on my form it'd be...

    Code:
    PictureBox1.Image = ReturnImage("filename")

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