无法将结果写入文本文件-C#中
本文关键字:文本 文件 -C# 结果 | 更新日期: 2023-09-27 18:27:30
我有以下代码从每个html页面中提取2个对象并将其保存在数组中。最后将其写入文本文件。但我在文本文件中看不到结果。
提前感谢
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();
我不能评论,因为我没有足够的分数,但完成后你会关闭流写入程序和文件吗?
如果是并且仍然没有输出,则调试程序。如果所有其他操作都失败,则打开流,写入一条测试行并关闭。如果在文件中看到文本,则在for循环中出现问题。
检查IIS进程是否有足够的权限写入此特定目录。