c#用StreamReader对文件读取

///
        ///类型:阵列反显,处理代码
        ///

        public void OnTypeArrayShowItem()
        {
            //找到和 当前选择的类型名 对应的 天线类型文件
            string folderPath = System.Environment.CurrentDirectory;
            DirectoryInfo TheFolder = new DirectoryInfo(folderPath + "\\MacroType");
            //遍历文件
            FileInfo currentTypeArrayFile = null;
            foreach (FileInfo nextInfo in TheFolder.GetFiles())
            {
                if (nextInfo.Name.Replace(".bat", "").Equals(this.Entity.AntennaType))
                {
                    currentTypeArrayFile = nextInfo;
                    break;
                }
            }
            //读取对应的天线类型文件
            // OpenText 创建一个UTF-8 编码的StreamReader对象
            StreamReader currentTypeArraySR = currentTypeArrayFile.OpenText();
            // 全部读完
            string currentTypeArrayStr = currentTypeArraySR.ReadToEnd();
            //Split方法:要省略返回的数组中的空数组元素,则为 System.StringSplitOptions.RemoveEmptyEntries;
            string[] currentTypeArrayArr = currentTypeArrayStr.Split(new string[] { ";\r\n" }, System.StringSplitOptions.RemoveEmptyEntries);
            //阵子/横向阵子数
            string BitNum = currentTypeArrayArr[2];
            //动态加载出阵列
            ArrayVisibility = "Visible";
            if ("直线阵列".Equals(currentTypeArrayArr[1]))
            {
                //创建直线阵列阵子间距界面
                var trendsViewModel = new TrendsViewModel(this.Messenger, this.UserLogin);
                if (BitNum != null && BitNum != "")
                {
                    trendsViewModel.CreatLostFocus(int.Parse(BitNum), "1");
                    trendsViewModel.WriteBitNum(currentTypeArrayArr[3]);
                    BitViewModel = trendsViewModel;
                }
            }
            else if ("交叉阵列".Equals(currentTypeArrayArr[1]))
            {
                //纵向阵子数
                string PortraitBitNum = currentTypeArrayArr[3];
                //交叉点左通道数
                string CrossLeftBitNum = currentTypeArrayArr[4].Split(',')[0];
                //交叉点上通道数
                string CrossTopBitNum = currentTypeArrayArr[4].Split(',')[1];



                //创建交叉阵列阵子间距界面
                var transverseTrendsViewModel = new TrendsViewModel(this.Messenger, this.UserLogin);
                transverseTrendsViewModel.CreatLostFocus(int.Parse(BitNum), int.Parse(PortraitBitNum), CrossLeftBitNum, CrossTopBitNum);
                transverseTrendsViewModel.WriteBitNum(currentTypeArrayArr[5]);
                BitViewModel = transverseTrendsViewModel;
            }


            

        }

你可能感兴趣的:(c#用StreamReader对文件读取)