Sytem.IO.IOException:文件“XXX”正由另一进程使用,因此该进程无法访问该文件

程序是这样的

        public struct Point
        {
            public double X;
            public double Y;
        }
        public void ReadTxtAndSaveAsDir()
        {
            FileSystemWatcher watcher = new FileSystemWatcher();
            string path = "D:\\Zane自动合成";
            //判断文件夹是否存在
            if (Directory.Exists(path))
            {
                DirectoryInfo directoryInfo = new DirectoryInfo(path);
                FileInfo[] files = directoryInfo.GetFiles();
                for (int i = files.Length - 1; i < files.Length; i++)
                {
                    if (files[i].Extension.Equals(".txt"))   //判断是否为txt文件
                    {
                        //文本文件完整路径\并且读入所有行
                        string[] strs = File.ReadAllLines(path +"/"+ files[i].Name);
                        // 创建字典
                        Dictionary<double, double> myDictionary = new Dictionary<double, double>();
                        // 让过前两行,从第三行开始处理
                        try
                        {
                            for (int j = 2; j < strs.Length; j++)
                            {
                                string line = strs[j];
                                // 拆分行
                                string[] v = line.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                                Point p;
                                // 获取Y(第一列)        
                                p.X = double.Parse(v[0]);
                                // 获取Y(第二列)        
                                p.Y = double.Parse(v[1]);
                                myDictionary.Add(p.X, p.Y);
                            }
                            strs = null;
                            // 至此,所有的数据点都在字典中了……  

                            //if (myDictionary.ContainsKey(274) || myDictionary.ContainsKey(269))
                            //{}
                            double x = myDictionary[274];
                            double y = myDictionary[269];
                            //double sub = x-y;
                            double div = x / y;
                        WriteIn(x, y, div);
                        textBox2.AppendText(
                                "274nm = " + x + ", " + "269nm = " + y + ", " + "274nm / 269nm = " + div+"\r\n");
                            if (div > 1.2 && x > 0.01)
                            {
                                Collect();
                            }
                    }
                    catch (FormatException)
                        { }
                    }
                }
            }
            else { Directory.CreateDirectory(path); }
        }

其他部分都能很好的运行,但是每次到
string[] strs = File.ReadAllLines(path +"/"+ files[i].Name);
这个部分就会报错
请大神指导

1.for (int i = files.Length - 1; i < files.Length; i++) 确定不是 i = 0 开始?
2.查看下你的任务管理器是不是已经有该进程在运行?也就是说你点了关闭按钮其实你的程序还有线程在运行导致你第再次打开的时候实际有两个或者多个进程在运行

这个文件是否被别的程序也在读写占用了,或者杀毒软件的干扰。把多余进程关闭,杀毒软件关闭,必要的时候重新启动,再试