Windows Phone 7ゲームで作業していて、レベルをテキストファイルに保存し、それを2D配列にロードしたいのですが、txtファイルのコンテンツインポーターがないため、分離ストレージマネージャーを使用しました
protected void read_lvl()
{
IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication();
IsolatedStorageFileStream fileStream = myIsolatedStorage.OpenFile("myFile.txt", FileMode.Open, FileAccess.Read);
using (StreamReader reader = new StreamReader(fileStream))
{ //Visualize the text data in a TextBlock text
while (!reader.EndOfStream)
{
//for each row
for (int i = 0; i < rows; i++)
{
//read in the line
string myLine = reader.ReadLine();
//take out the commas
string[] row = myLine.Split(',');
//convert to string to ints
//and feed back into array
int[] nRow = new int[row.Length];
for(int r=0; r<columns;r++){
nRow[r] =Convert.ToInt32(row[r]);
myreadArray[i, r] = nRow[r];
}
}
}
}
}
.txt
これは、保存されたゲームの状態などをロードするのに適していますが、複数のファイルに複数のレベルを設定したいので、代わりにこれを使用してみました。
//stream from file
Stream stream = TitleContainer.OpenStream("myFile.txt");
//make a stream reader from the stream
using (StreamReader sreader = new StreamReader(stream))
しかし、同じエラーがスローされます。このファイルタイプを処理するインポーターはありません。
何をしますか?