我正在开发一个 windows phone 7 游戏,我已经将关卡保存在一个文本文件中,我想将它加载到一个二维数组中,但是没有 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))
但它抛出了同样的错误:没有处理这种文件类型的进口商。
做什么?