Texture2D.FromFile Method (GraphicsDevice, Stream, TextureCreationParameters)

This method is available only when developing for Windows.
Creates a texture resource from a stream, specifying the parameters to be used in creation of the texture.

Namespace: Microsoft.Xna.Framework.Graphics
Assembly: Microsoft.Xna.Framework (in microsoft.xna.framework.dll)

public static Texture2D FromFile (
         GraphicsDevice graphicsDevice,
         Stream textureStream,
         TextureCreationParameters creationParameters


The graphics device to use to create the texture resource.
Stream containing the texture data.
The parameters to use when creating this texture.

Return Value

The texture resource that has been created on the specified graphics device.

Exception typeCondition
ArgumentNullException textureStream is null. The stream passed into this method cannot be null.
NotSupportedException textureStream is not readable. Streams passed into this method must be readable.
EndOfStreamException textureStream does not contain enough data to support this call.

The supported texture image file formats are described by the ImageFileFormat enumeration.

Windows XP SP2, Windows Vista

Community Additions