각 html 페이지에서 2 개의 오브젝트를 추출하여 배열로 저장하는 다음 코드가 있습니다. 그리고 마지막으로 텍스트 파일에 씁니다. 하지만 텍스트 파일에서 결과를 볼 수 없습니다. 사전에텍스트 파일에 결과를 쓸 수 없습니다 - C#
감사
for (int y = 0; y < 9; y++)
{
if (IDs[y] == null)
break;
else
{
string item = Convert.ToString(IDs[y]);
string url = "http://mu/tr/";
string URL = url+item;
WebClient web = new WebClient();
String html= web.DownloadString(URL);
MatchCollection m1 = Regex.Matches(html, @"<strong>\s*(.+?)\s*</strong>");
MatchCollection m2 = Regex.Matches(html, @"<title>\s*(.+?)\s*</title>");
foreach(Match m in m1)
{
string Gre = m.Groups[1].Value;
string sic = m.Groups[2].Value;
ITEM [y][0] = Convert.ToString(item);
ITEM [y][1] = sic;
ITEM [y][2] = Gre;
}
}
}
for (int row = 0; row < 9; row++)
{
for (int col = 0; col < 3; col++)
{
SIC.Write(ITEM[row][col] + " ");
}
SIC.WriteLine();
}
SIC.WriteLine();
문제가있는 곳을 코드에서 확인한 적이 있습니까? 정규 표현식이 실제로 일치합니까? 9 개의 빈 줄과 같은 * 아무것도 * 텍스트 파일에 있습니까? 프로그램이 예외를 던지고 있습니까? –
@JimMischel에 감사드립니다. YES 브레이크 포인트를 사용하여 찾은 일치 항목을 찾습니다. 또한 텍스트 파일에 빈 줄이 있다고 확신합니다. –
SIC는 무엇입니까? StreamWriter? 당신은 당신의 작가를 인스턴스화하고 당신이 쓰려고하는 파일의 경로는 무엇입니까? – Sam