Wrox Programmer Forums
|
C# 2008 aka C# 3.0 Discuss the Visual C# 2008 (aka C# 3.0) language
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2008 aka C# 3.0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 12th, 2010, 10:02 AM
Authorized User
 
Join Date: Mar 2010
Posts: 27
Thanks: 2
Thanked 1 Time in 1 Post
Default FileUpload

Hello..
How I can determine the width and Height for the PostedFile in FileUpload.
 
Old April 12th, 2010, 10:10 AM
Friend of Wrox
 
Join Date: Dec 2008
Posts: 238
Thanks: 2
Thanked 20 Times in 19 Posts
Default

Code:
System.Drawing.Image image = System.Drawing.Image.FromFile(filePath);
int height = image.Height;
int width = image.Width;
 
Old April 12th, 2010, 10:12 AM
Authorized User
 
Join Date: Mar 2010
Posts: 27
Thanks: 2
Thanked 1 Time in 1 Post
Default

What is this?
and where I must write it?
 
Old April 12th, 2010, 10:24 AM
Authorized User
 
Join Date: Mar 2010
Posts: 27
Thanks: 2
Thanked 1 Time in 1 Post
Default

hi.
what is this and how I can use it :
Code:
System.Drawing.Image image = System.Drawing.Image.FromFile(filePath);
int height = image.Height;
int width = image.Width;
 
Old April 12th, 2010, 02:36 PM
Authorized User
 
Join Date: Mar 2010
Posts: 27
Thanks: 2
Thanked 1 Time in 1 Post
Default

I used this code

Code:
protected void Button1_Click(object sender, EventArgs e)
    {
         Stream s = FileUpload1.PostedFile.InputStream;   
        Image i= System.Drawing.Image.FromStream(s);   
                      
        intFileWidth = i.PhysicalDimension.Width;   
        intFileHeight = i.PhysicalDimension.Height;  
        
      
    }
but this error occurred

Compiler Error Message: CS0029: Cannot implicitly convert type 'System.Drawing.Image' to 'System.Web.UI.WebControls.Image'


Please Help me.
 
Old April 12th, 2010, 04:44 PM
Friend of Wrox
 
Join Date: Dec 2008
Posts: 238
Thanks: 2
Thanked 20 Times in 19 Posts
Default

You need to specify the namespace:
Code:
        Stream stream = FileUpload1.FileContent;
        System.Drawing.Image image = System.Drawing.Image.FromStream(stream);
        Label1.Text = image.Width.ToString();
        Label2.Text = image.Height.ToString();





Similar Threads
Thread Thread Starter Forum Replies Last Post
Fileupload in Ajax bobwith5 ASP.NET 2.0 Professional 3 October 18th, 2008 09:59 AM
FileUpload control aliirfan84 ASP.NET 2.0 Professional 1 June 2nd, 2007 03:37 PM
FileUpload Control MunishBhatia ASP.NET 2.0 Basics 2 December 6th, 2006 04:03 AM
FileUpload FIlter tony_j_hug ASP.NET 2.0 Basics 1 October 28th, 2005 06:55 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.