| | |
Get Image From file
Please support our VB.NET advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
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 |
.net .net2008 30minutes 2005 2008 access account arithmetic array basic beginner browser button buttons center check code component connectionstring crystalreport cuesent data database databasesearch datagrid datagridview date datetimepicker design designer dissertation dissertations dissertationtopic dropdownlist excel fade file-dialog filter folder forms ftp generatetags hardcopy html images input insert intel monitor net networking open output panel passingparameters peertopeervideostreaming picturebox picturebox1 port printing problem problemwithinstallation project reports" searchvb.net select serial settings shutdown sqlserver survey tcp temperature text textbox timespan toolbox transparency trim updown user usercontrol vb vb.net vb.netcode vb.netformclosing()eventpictureboxmessagebox vb2008 vbnet view visual visualbasic visualbasic.net visualstudio visualstudio.net visualstudio2008 web winforms wpf wrapingcode year






