.txt ファイルからデータをロードする整数の 2D 配列を作成しようとしていますが、このコード行をコンパイルするstring line = stream.ReadLine();
と、スレッドのタイトルと次のエラーが表示されます。
メソッドにアクセスしようとして失敗しました、System.IO.StreamReader..ctor(System.String)
PC と WP7/360 の間で txt ファイルの使用に違いがある可能性があることは理解していますが、大学の家庭教師が作成したアプリが WP7 ハンドセットで .txt ファイルを使用したため、それが可能であると確信しています。 Windows Phone でファイルを正しく読み取るには?
追加情報が必要な場合は、txt を int 配列にロードする方法全体を次に示します。
public void loadMap(string mapFileName)
{
int x = 0, y = 0;
StreamReader stream = new StreamReader(mapFileName);
do
{
string line = stream.ReadLine();
string[] numbers = line.Split(',');
foreach (string e in numbers)
{
int tile = int.Parse(e);
this.tileID[x, y] = tile;
x++;
}
y++;
}
while (!stream.EndOfStream);
xSize = x;
ySize = y;
stream.Close();
}
編集
IsolatedStorageメソッドを使用して新しいエラーが発生しましたが、現在は進行中ですが、解析コードの前にこのコードを追加しました:
var store = IsolatedStorageFile.GetUserStoreForApplication();
var readStream = new IsolatedStorageFileStream(mapFileName, FileMode.Open, store);
var stream = new StreamReader(readStream);
そして今ここに:var readStream = new IsolatedStorageFileStream(mapFileName, FileMode.Open, store);
私はエラーが発生します:
IsolatedStorageFileStream に対する操作は許可されていません。
何か案は?