日期:2014-05-17  浏览次数:20725 次

...because it is being used by anothr process求解!!!
最近用户不能访问站点,打开服务器一看,提示一个文本文件被一进程使用,无法访问。
在网上查了资料,说是读取的流没有关闭,但我的关闭了的呀!
而另一个站点采用了同一段代码,没有报过这样的错误!
唯一不同的是,报错的站点,访问的用户在日本。但也是同一个集团的,在同一个网络内的。

以下为两个站点的代码比较。

 protected void Page_Load(object sender, EventArgs e)
        {
            year =  DateTime.Now.Year.ToString();
            DirectoryInfo dirWeeks = new DirectoryInfo(@"C:\Inetpub\wwwroot\ProductionPlan\" + year);
            weeks = dirWeeks.GetDirectories();
            selectedWeek = weeks[weeks.Length - 1].ToString().Substring(0, 2)+"W";//嵟岪堦廃
            lbWeek.Text = selectedWeek;//嵟岪堦廃
            if (!IsPostBack)
            {

              //  BindCombox();  
                WriteLog();
                InitLinkButton();               
                lbYear.Text = year;               
                lbWeek.Text = selectedWeek;
                lbKind.Text = ddlPlan.SelectedValue;               
            };
            
        }

        private void WriteLog()
        {
            StreamWriter sw;
            System.IO.Directory.CreateDirectory(@"C:\Information");
            sw = File.AppendText(@"C:\Information\logPH.txt");
            IPHostEntry host = Dns.GetHostEntry(GetClientIP());
            string MyHost = host.HostName;
            //  string Name=User.Identity.Name.ToString();
            sw.WriteLine("庡婘?崋丗" + MyHost + ",????丗" + DateTime.Now);
            //sw.WriteLine("庡婘?崋丗" + hname + ",梡?柤:" + Request.ServerVariables["LOGON_USER"] + "-----------" + DateTime.Now);