public FolderTraceEntry(string folderName, FolderTrace owner, bool includeSubfolders)
 {
     this.folderName = folderName;
     try
     {
         folderInfo = new DirectoryInfo(folderName);
     }
     catch (Exception ex)
     {
         EventLogger.RecordException(Constants.CommonLibraryEventSource, ex);
     }
     this.owner = owner;
     this.includeSubfolders = includeSubfolders;
 }
 public FolderTraceEntry(string folderName, FolderTrace owner)
     : this(folderName, owner, false)
 {
 }
        private void LoadProfile(string selectedFileName)
        {
            try
            {
                gridTraces.Rows.Clear();
                gridEvents.Rows.Clear();
                gridTraceFolders.Rows.Clear();

                XmlTextReader xmlReader = new XmlTextReader(selectedFileName);
                while (xmlReader.Read())
                {
                    if (xmlReader.NodeType == XmlNodeType.Element && xmlReader.Name == traceElementName)
                    {
                        string traceName = xmlReader.GetAttribute(traceNameAttributeName);
                        string traceGuid = xmlReader.GetAttribute(traceGuidAttributeName);
                        if (traceGuid != null)
                        {
                            FolderTrace trace = new FolderTrace(traceName, FolderTraceState.Stopped, new Guid(traceGuid));
                            while (xmlReader.Read())
                            {
                                if (xmlReader.NodeType == XmlNodeType.Element && xmlReader.Name == folderElementName)
                                {
                                    string folderPath = xmlReader.GetAttribute(folderPathAttributeName);
                                    bool includeSubDirectories = !(xmlReader.GetAttribute(folderIncludeSubfoldersAttributeName) == falseValue);
                                    trace.Items.Add(new FolderTraceEntry(folderPath, trace, includeSubDirectories));
                                }
                                if (xmlReader.NodeType == XmlNodeType.EndElement && xmlReader.Name == traceElementName)
                                {
                                    break;
                                }
                            }
                            int newRowIndex = gridTraces.Rows.Add(trace.Name, "Stopped", trace.Items.Count);
                            gridTraces.Rows[newRowIndex].Tag = trace;
                        }
                    }
                }
                if (gridTraces.Rows.Count > 0)
                {
                    ActiveFolderTrace = (FolderTrace)gridTraces.Rows[0].Tag;
                }
            }
            catch (Exception ex)
            {
                EventLogger.RecordException(Constants.AdminApplicationEventSource, ex, "Failed to load profile: ");
                FormHelper.ShowErrorMessage("Failed to load profile. The file can be probably corrupt.\r\nDetails:\r\n" + ex.Message);
            }
        }