Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
Image Class
Image Methods
FromFile Method
 FromFile Method (String)
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
Image..::.FromFile Method (String)

Creates an Image from the specified file.

Namespace:  System.Drawing
Assembly:  System.Drawing (in System.Drawing.dll)
Visual Basic (Declaration)
Public Shared Function FromFile ( _
    filename As String _
) As Image
Visual Basic (Usage)
Dim filename As String
Dim returnValue As Image

returnValue = Image.FromFile(filename)
C#
public static Image FromFile(
    string filename
)
Visual C++
public:
static Image^ FromFile(
    String^ filename
)
JScript
public static function FromFile(
    filename : String
) : Image

Parameters

filename
Type: System..::.String
A string that contains the name of the file from which to create the Image.

Return Value

Type: System.Drawing..::.Image
The Image this method creates.
ExceptionCondition
OutOfMemoryException

The file does not have a valid image format.

-or-

GDI+ does not support the pixel format of the file.

FileNotFoundException

The specified file does not exist.

ArgumentException

filename is a Uri.

The file remains locked until the Image is disposed.

If the file does not have a valid image format or if GDI+ does not support the pixel format of the file, this method throws an OutOfMemoryException exception.

NoteNote:

The Image class does not support alpha transparency in bitmaps. To enable alpha transparency, use PNG images with 32 bits per pixel.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker