首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

The process cannot access the file because it is being used by another process

2013-06-19 
The process cannot access the filebecause it is being used by another processpublic void WriteLogTo

The process cannot access the file because it is being used by another process
public void WriteLogToLocal(string v_Msg, string lx)
        {
            try
            {
                string path = HttpRuntime.AppDomainAppPath + @"logs" + DateTime.Now.ToString("yyyy") + "\" + DateTime.Now.ToString("yyyy-MM") + lx + "\";
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                using (StreamWriter writer = new StreamWriter(path + DateTime.Now.ToString("yyyy-MM-dd") + ".log", true, System.Text.Encoding.Default, 0x400))
                {
                    writer.WriteLine(DateTime.Now.ToString() + "  ---  " + v_Msg);
                    writer.Flush();
                    writer.Close();
                    writer.Dispose();
                }
            }
            catch (Exception ex)
            {
                
            }
        }

这个是在webservice中记录日志的方法,偶尔会报The process cannot access the file 路径 because it is being used by another process的错误,不知道是哪里的问题,急求解决 异常
[解决办法]
是不是什么地方漏关闭了 

热点排行