| | |
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
![]() |
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 2008 access add advanced application array assignment basic beginner box browser button buttons center click client code combo convert cpu cuesent data database datagrid datagridview datetimepicker designer dissertation dissertations dissertationtopic eclipse editvb.net employees excel exists filter forms function html images isnumericfuntioncall listview map mobile module msaccess mssqlbackend mysql net number open page pan panel pdf picturebox picturebox2 port position print printing printpreview read record regex reuse right-to-left save search serial settings socket sorting sqldatbase sqlserver storedprocedure temp textbox timer timespan transparency txttoxmlconverter usercontol vb vb.net vba vbnet vista visual visualbasic visualbasic.net visualstudio.net web winsock wpf wrapingcode xml year






