Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

ContentManager Constructor (IServiceProvider, String)

Initializes a new instance of ContentManager.

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

public ContentManager (
         IServiceProvider serviceProvider,
         string rootDirectory
)

Parameters

serviceProvider
Type: IServiceProvider
The service provider the ContentManager should use to locate services.
rootDirectory
Type: String
The root directory to search for content.

Exception typeCondition
ArgumentNullException The serviceProvider or rootDirectory parameter is null.

Bb195762.caution(en-us,XNAGameStudio.41).gifCaution

When creating a new ContentManager, if no instance of Game is otherwise required by the application, it is often better to create a new class that implements the IServiceProvider interface rather than creating an instance of Game just to create a new instance of GraphicsDeviceManager.

To create a ContentManager that uses Game.Services and searches for resources from the root of the C: drive:

ContentManager contentManager = new ContentManager( Services, "C:\\" );

Xbox 360, Windows 7, Windows Vista, Windows XP, Windows Phone

Community Additions

ADD
Show:
© 2015 Microsoft