Esempio n. 1
0
 public FileController()
 {
     files       = FilesContainer.getInstance();
     directories = new List <directory>();
 }
Esempio n. 2
0
        public void Insertpathtoxmldoc()
        {
            FilesContainer files = FilesContainer.getInstance();
            XmlDocument    xd    = new XmlDocument();
            string         path  = GetXMLpath() + "/filepaths.xml";
            FileStream     lfile = new FileStream(path, FileMode.Open); //start a bit steam of the given file

            xd.Load(lfile);                                             // xml doc class use the data steam

            if (files.pcaps.Count > 0)
            {
                XmlElement pcaps = xd.CreateElement("pcapPaths");
                foreach (var item in files.pcaps)
                {
                    XmlElement pcap     = xd.CreateElement("pcappath");
                    XmlText    pcaptext = xd.CreateTextNode(item);
                    pcap.AppendChild(pcaptext);
                    pcaps.AppendChild(pcaps);
                }
                xd.DocumentElement.AppendChild(pcaps);
                files.pcaps.Clear();
            }
            if (files.pdfs.Count > 0)
            {
                XmlElement pdfpaths = xd.CreateElement("pdfPaths");
                foreach (var item in files.pdfs)
                {
                    XmlElement pdfs     = xd.CreateElement("pdfpath");
                    XmlText    pdfstext = xd.CreateTextNode(item);
                    pdfs.AppendChild(pdfstext);
                    pdfpaths.AppendChild(pdfs);
                }
                xd.DocumentElement.AppendChild(pdfpaths);
                files.pdfs.Clear();
            }
            if (files.PictureFiles.Count > 0)
            {
                XmlElement piturefiles = xd.CreateElement("piturePaths");
                foreach (var item in files.PictureFiles)
                {
                    XmlElement picturepaths = xd.CreateElement("piturePath");
                    XmlText    picturepath  = xd.CreateTextNode(item);
                    picturepaths.AppendChild(picturepath);
                }
                xd.DocumentElement.AppendChild(piturefiles);
                files.PictureFiles.Clear();
            }
            if (files.xmls.Count > 0)
            {
                XmlElement xmlfiles = xd.CreateElement("xmlPaths");
                foreach (var item in files.xmls)
                {
                    XmlElement xmlpath = xd.CreateElement("xmlPaths");
                    XmlText    xmltext = xd.CreateTextNode(item);
                    xmlpath.AppendChild(xmltext);
                    xmlfiles.AppendChild(xmlpath);
                }
                xd.DocumentElement.AppendChild(xmlfiles);
                files.xmls.Clear();
            }
            if (files.Texts.Count > 0)
            {
                XmlElement txtfiles = xd.CreateElement("txtpaths");
                foreach (var item in files.Texts)
                {
                    XmlElement txtpath = xd.CreateElement("txtpath");
                    XmlText    xmlText = xd.CreateTextNode(item);
                    txtpath.AppendChild(xmlText);
                    txtfiles.AppendChild(txtpath);
                }
                xd.DocumentElement.AppendChild(txtfiles);
                files.Texts.Clear();
            }
            if (files.Csvs.Count > 0)
            {
                XmlElement csvfiles = xd.CreateElement("csvpaths");
                foreach (var item in files.Csvs)
                {
                    XmlElement csvpath = xd.CreateElement("csvpath");
                    XmlText    xmlText = xd.CreateTextNode(item);
                    csvpath.AppendChild(xmlText);
                    csvfiles.AppendChild(csvpath);
                }
                xd.DocumentElement.AppendChild(csvfiles);
                files.Csvs.Clear();
            }
            lfile.Close();
            xd.Save(path);
        }