private List GetCaptureFilesPath()

in src/PTFTestLogger/TxtToJSON.cs [124:178]


        private List<string> GetCaptureFilesPath()
        {
            List<string> captureFolders = new List<string>();
            DirectoryInfo info = new DirectoryInfo(Directory.GetCurrentDirectory());
            bool existBatch = false;
            if (info.FullName.EndsWith("Batch"))
                existBatch = true;
            string fullPath = existBatch ? info.Parent.FullName : info.FullName;
            string cfgFolder = Path.Combine(fullPath, "bin");
            try
            {
                string[] ptfconfigFiles = Directory.GetFiles(cfgFolder, "*.ptfconfig", SearchOption.TopDirectoryOnly);
                foreach (string configFile in ptfconfigFiles)
                {
                    XmlDocument configXml = new XmlDocument();
                    configXml.Load(configFile);

                    XmlNodeList groupNodes = configXml.GetElementsByTagName("Group");
                    if (groupNodes == null || groupNodes.Count <= 0) { continue; }

                    bool isNetworkCaptureEnabled = false;
                    string captureFileFolder = null;
                    foreach (XmlNode gNode in groupNodes)
                    {
                        if (gNode.Attributes["name"].Value == "NetworkCapture")
                        {
                            foreach (XmlNode pNode in gNode.ChildNodes)
                            {
                                if (pNode.Attributes["name"].Value == "Enabled")
                                {
                                    isNetworkCaptureEnabled = bool.Parse(pNode.Attributes["value"].Value);
                                }
                                if (pNode.Attributes["name"].Value == "CaptureFileFolder")
                                {
                                    captureFileFolder = pNode.Attributes["value"].Value;
                                }
                            }
                            break;
                        }
                    }

                    if (!isNetworkCaptureEnabled) { continue; }

                    if (!string.IsNullOrEmpty(captureFileFolder))
                    {
                        captureFolders.Add(captureFileFolder);
                    }
                }
            }
            catch
            {
                return captureFolders;
            }
            return captureFolders;
        }