| | |
Get Image From file
Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Apr 2008
Posts: 75
Reputation:
Solved Threads: 0
I want to get image from the file..I m able to do it....But mine code do not close the file,after getting the image,I want to close the file.Cz after getting the image,I want to delete that file.....on Deleteing error is dere file is user by another process...
IS Image.FromFile do not close the file????
Suppose I convert string to fileinfo object
[code]
dim a as fileinfo=new fileinfo(sFileName)
How to close the file,Can somebody tell me?
VB.NET Syntax (Toggle Plain Text)
Public Sub GetImagesContent(ByVal sFileName As String) Try Dim sExtension As String Dim img As System.Drawing.Image sExtension = System.IO.Path.GetExtension(sFileName) If Trim(sExtension) = ".bmp" Or _ Trim(sExtension) = ".jpg" Or _ Trim(sExtension) = ".jpeg" Or _ Trim(sExtension) = ".gif" Or _ Trim(sExtension) = ".png" Then img = Image.FromFile(sFileName) ImgThumbNailView.Images.Add(img) End if
IS Image.FromFile do not close the file????
Suppose I convert string to fileinfo object
[code]
dim a as fileinfo=new fileinfo(sFileName)
How to close the file,Can somebody tell me?
•
•
Join Date: Apr 2008
Posts: 75
Reputation:
Solved Threads: 0
hi frnd, find the solution of mine code-
Can u provide me the code of urs,CZ i didnt know how to get image using from stream
VB.NET Syntax (Toggle Plain Text)
Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Try Dim img As Image Dim sFileName As String = "D:\Documents and Settings\Mansi\Desktop\Winter.jpg" img = Image.FromFile(sFileName) ImageList1.Images.Add(img) PictureBox1.Image = ImageList1.Images.Item(0) img.Dispose() System.IO.File.Delete(sFileName) Catch ex As Exception MsgBox(ex.Message) End Try End Sub End Class
Can u provide me the code of urs,CZ i didnt know how to get image using from stream
Last edited by mansi sharma; Jul 3rd, 2009 at 2:42 pm.
Use FileStream class:
VB.NET Syntax (Toggle Plain Text)
Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Try Dim img As Image Dim sFileName As String = "D:\Documents and Settings\Mansi\Desktop\Winter.jpg" Dim fs as new System.IO.FileStream(sFileName,System.IO.FileMode.Open) img = Image.FromStream(fs) fs.close() ImageList1.Images.Add(img) PictureBox1.Image = ImageList1.Images.Item(0) img.Dispose() System.IO.File.Delete(sFileName) Catch ex As Exception MsgBox(ex.Message) End Try End Sub End Class
Failure is not fatal, but failure to change might be. - John Wooden
![]() |
Similar Threads
- Extract header info from image file (Python)
- Opening Image file? (C)
- save an image into a file using c++ (C++)
- how to display an attached image file in email (ASP)
- Python and the JPEG Image File, Part 2, The Image (Python)
- Python and the JPEG Image File, Part 1, The Header (Python)
- HELP! Html image file! (HTML and CSS)
- hi, how to set a proper path of a image file, many thanks! (C#)
Other Threads in the VB.NET Forum
- Previous Thread: How to build the correct way of n-tier apps without service and remoting?
- Next Thread: how to upload a photo to a form in vb.net
| Thread Tools | Search this Thread |
"crystal .net .net2005 30minutes 2005 2008 access account arithmetic array assignment basic binary bing box button buttons center check code component connectionstring convert cpu crystalreport data database databasesearch datagrid datagridview design dissertation dissertations dissertationthesis dosconsolevb.net dropdownlist editvb.net excel file-dialog firewall folder ftp hardcopy image images insert isnumericfuntioncall login math memory mobile ms mssqlbackend mysql navigate net networking opacity output passingparameters peertopeervideostreaming picturebox1 port printpreview problemwithinstallation project record reports" reuse save savedialog serial soap storedprocedure string tcp temp text textbox timer toolbox trim update updown useraccounts usercontrol vb vb.net vb.netcode vb.netformclosing()eventpictureboxmessagebox vb.nettoolboxvisualbasic2008sidebar vb2008 vbnet view visual visualbasic visualbasic.net visualstudio web wpf






