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();
}
}
내 브레이크 포인트가 첫 번째 줄에 있습니다 (foreach 조건) – phadaphunk
(대답에 대한 답글); 만약 당신이'BinaryWriter'를 써서 파일을 작성했다면, 질문에서 그 파일을 지워야하고 아마도'.txt' 파일을 호출해서는 안됩니다. –
고마워요. .bin에 대한 모든 확장을 변경했고 모든 것이 잘 동작했습니다. 의견을 답변으로 작성하여 허용으로 표시 할 수 있습니다. 감사합니다. – phadaphunk