Export (0) Print
Expand All

StorageContainer.TitleLocation Property

Gets the file path to the location of the title storage space.

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

public static string TitleLocation { get; }

Property Value

The title's install location based on the current platform.

Use this member to create full paths to files in the same location as the game executable. For example:

using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Storage;
using System.IO;
using System.Xml.Serialization;
using System.Diagnostics;
/// <summary>
/// This method opens a file using System.IO classes and the
/// TitleLocation property.  It presumes that a file named
/// ship.dds has been deployed alongside the game.
/// </summary>
private static void DoOpenFile()
{
    FileStream file = OpenTitleFile(
        "ship.dds", FileMode.Open, FileAccess.Read);
    Console.WriteLine("File Size: " + file.Length);
    file.Close();
}
private static FileStream OpenTitleFile(
    string filename, FileMode mode, FileAccess access)
{
    string fullpath = Path.Combine(StorageContainer.TitleLocation, filename);
    return File.Open(fullpath, mode, access);
}

Xbox 360, Windows XP SP2, Windows Vista, Zune

Community Additions

ADD
Show:
© 2015 Microsoft