注册 登录
编程论坛 C# 论坛

有哪位大神可以帮忙解释一下这段代码的意思?

小刀神 发布于 2019-03-04 17:41, 2194 次点击
其中,using在这里是起到什么作用?具体是什么意思?
代码如下:
程序代码:
ProjectName = (InPath + "/Project/ProjectName/ProjectName.LMPN");
                                        String line = String.Empty;
                                        String ProjectPath;
                                        using(StreamReader reader = new StreamReader(InPath + "/Project/ProjectName/ProjectName.LMPN"))
                                        {
                                            line = reader.ReadLine();
                                            while(line != "" && line != null)
                                            {
                                                IfPath = (InPath + "/Project/ProjectPath");
                                                if(IfPath == true)
                                                {
                                                    IfPath = (InPath + "/Project/ProjectPath/" + line + ".LMPP");
                                                    if(IfPath == true)
                                                    {
                                                        ProjectPath = (InPath + "/Project/ProjectPath/" + line + ".LMPP");
                                                        switch (ProjectPath)
                                                        {
                                                            case "":
                                                                ListBox_历史项目.Items.Add(line + "                   路径为空");
                                                                break;
                                                            case "DefaultProjectPath":
                                                                ListBox_历史项目.Items.Add(line + "                   默认路径");
                                                                break;
                                                            default:
                                                                ListBox_历史项目.Items.Add(line + "                   " + ProjectPath);
                                                                break;
                                                        }
                                                    }else
                                                    {
                                                        ListBox_历史项目.Items.Add(line + "                   项目路径文件不存在");
                                                    }
                                                }else
                                                {
                                                    MessageBox.Show("缺少ProjectPath文件夹及其相关文件!","警告");
                                                    this.Close();
                                                }
                                                
                                               // Console.WriteLine(line);
                                                line = reader.ReadLine();
                                            }
                                        }
0 回复
1