我正在尝试从二进制文件中读取BinaryReader
.
这就是我所说的阅读方法:
foreach (Movie film in TreeBuilder.myMovies)
{
if (File.Exists(@"C:\Users\DaPhunk\Documents\Visual Studio 2010\Projects\YLK\Binary\" + film.MovieName + ".txt"))
{
string[] myArray = operationManager.BinaryReading(film.MovieName);
if (myArray != null)
{
this.textStarring.Text = myArray[1];
this.textProduced.Text = myArray[2];
this.textMusic.Text = myArray[3];
this.textYear.Text = myArray[4];
this.textTime.Text = myArray[5];
}
else
{
MessageBox.Show("An error occured");
}
}
这是我的阅读方法:
public string[] BinaryReading(string name)
{
FileStream myStream = new FileStream(@"C:\Users\DaPhunk\Documents\Visual Studio 2010\Projects\YLK\Binary\" + name + ".txt", FileMode.Open);
BinaryReader reader = new BinaryReader(myStream);
string loadString = reader.ReadString();
string[] loadArray = loadString.Split(',');
reader.Close();
myStream.Close();
return loadArray;
}
现在这些线中的某些东西不起作用。我的文件不是空的,因为它只是一个字符串,我可以读取文件中的内容。
我的问题是我试图找出断点有什么问题,但是一旦我越过这条线:
string loadString = reader.ReadString();
我的程序再次开始运行。这怎么可能?这使我无法在方法调用后检查我的内容String[]
以及我的值是什么。
知道为什么吗?提前致谢。
更新 :
我试图把我的移到breakpoint
这里
string[] loadArray = loadString.Split(',');
但是我的程序永远不会停止,所以它永远不会超过上一行。
这也是我的写作方法:
foreach (Movie film in TreeBuilder.myMovies)
{
if (film.MovieName == name)
{
FileStream myStream = new FileStream(@"C:\Users\DaPhunk\Documents\Visual Studio 2010\Projects\YLK\Binary\" + film.MovieName + ".txt", FileMode.Create);
BinaryWriter writer = new BinaryWriter(myStream);
writer.Write(film.MovieName + "," + starring + "," + produced + "," + music + "," + year + "," + lenght);
writer.Close();
myStream.Close();
}
}