2017-01-12 2 views
0

다음은 내 BinaryReader 루프입니다. 진행 상황을 보려면 단계별로 시도했지만 위치 변수 설정으로 돌아 가면 "433939"에서 "433941"로 이동합니다. else는이 루프와 상호 작용하며,이 루프를 전혀 거치지 않지만 433939에서 433940으로 이동하는 대신이 루프를 건너 뜁니다. 내가 여기서 누락 된 것이 있습니까? 내가 이상 단계 또는 중대한에 모든 인 점은 전혀 도움이되지 않습니다 휴식 말했듯이, 잘못 어디로 정말 ​​보이지 않아요BinaryReader 미리 위치에서 건너 뛰기

while (Binary.BaseStream.Position < Binary.BaseStream.Length) 
{ 
    CurrentData = Binary.ReadByte().ToString("X2"); 
    Position = Binary.BaseStream.Position; 

    if (CurrentData == "FF") 
    { 
     if (ImageFound == false) 
     { 
      if (Binary.ReadByte().ToString("X2") == "D8") 
      { 
       Console.WriteLine("Header Found!"); 
       ImageFound = true; 
       Binary.BaseStream.Position = Position; 
       continue; 
      } 
     } 
     if (ImageFound == true) 
     { 
      if (Binary.ReadByte().ToString("X2") == "D9") 
      { 
       Console.WriteLine("Footer Fount!"); 
       ImageFound = false; 
       Image.Append(Binary.ReadByte().ToString("FFD9")); 
       File.WriteAllText(new Random().Next().ToString() + ".bin", Image.ToString()); 
       Console.ReadLine(); 
       continue; 
      } 
     } 
    } 
    if (ImageFound == true) 
    { 
     Image.Append(CurrentData); 
     continue; 
    } 
} 

.

답변

0

오, 나는 어리 석다. 나는 휴식을 취하거나 커피를 마셔야 할 필요가있다. 문제는 내가 비교를위한 입장을 전진시키고 실패한 경우 그것을 다시 놓지 않는 것이 었습니다.

if (Binary.ReadByte().ToString("X2") == "D9") 

그것에게 한 바이트를 진행하고 false를 반환, 그래서 난 그냥 추가 할 필요하고 다른

Binary.BaseStream.Position--; 
을 말하고 있었다