タイトル ストレージ領域の場所へのファイル パスを取得します。
名前空間: Microsoft.Xna.Framework.Storage
アセンブリ: Microsoft.Xna.Framework (microsoft.xna.framework.dll 内)
public static string TitleLocation { get; }
プロパティ値
現在のプラットフォームを基準とした、タイトルのインストール場所。
このメンバーを使用して、ゲームの実行可能ファイルと同じ場所にあるファイルへの完全パスを作成します。次に例を示します。
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