无法在文本文件中写入结果 - C#

时间:2014-10-23 12:53:46

标签: c#

我有以下代码从每个html页面中提取2个对象并将其保存在数组中。最后在textfile中写出来。但我无法在文本文件中看到结果。

提前致谢

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();

2 个答案:

答案 0 :(得分:0)

我无法发表评论,因为我没有足够的积分,但是当你完成时你是在关闭流编写器和文件吗?

如果是,仍然没有输出调试程序。如果所有其他方法都失败,则打开流写一条测试线并关闭。如果在文件中看到文本,则在for循环中出现问题。

答案 1 :(得分:0)

检查您的IIS进程是否有足够的权限写入此特定目录。