Example #1
0
 private static void FillChilds(XmlNodeList childs, MWRFileDirectory mwrDir)
 {
     if (childs.Count > 0)
     {
         foreach (XmlNode node in childs)
         {
             if (node.Name == "File")
             {
                 mwrDir.SubFiles.Add(new MWRFileInfo(node.Attributes["Name"].Value, int.Parse(node.Attributes["Size"].Value)));
             }
             else
             {
                 MWRFileDirectory mwrSub = new MWRFileDirectory(node.Attributes["Name"].Value);
                 FillChilds(node.ChildNodes, mwrSub);
                 mwrDir.SubFiles.Add(mwrSub);
             }
         }
     }
 }
Example #2
0
 private void GetObject(DirectoryInfo di, MWRFileDirectory root)
 {
     DirectoryInfo [] dSubs = di.GetDirectories();
     foreach (DirectoryInfo dsubInfo in dSubs)
     {
         MWRFileDirectory fDir = new MWRFileDirectory(dsubInfo.Name);
         GetObject(dsubInfo, fDir);
         root.SubFiles.Add(fDir);
     }
     FileInfo [] fInfos = di.GetFiles();
     foreach (FileInfo f in fInfos)
     {
         MWRFileInfo fFile = new MWRFileInfo(f.Name, f.Length);
         root.SubFiles.Add(fFile);
     }
 }
Example #3
0
 public static MWRFileBase Deserialize(string input)
 {
     XmlDocument xmlDoc = new XmlDocument();
     xmlDoc.LoadXml("<root>" + input + "</root>");
     XmlNode rootNode = xmlDoc.FirstChild.ChildNodes[0];
     MWRFileBase Root;
     if (rootNode.Name == "File")
     {
         Root = new MWRFileInfo(rootNode.Attributes["Name"].Value, int.Parse(rootNode.Attributes["Size"].Value));
     }
     else
     {
         Root = new MWRFileDirectory(rootNode.Attributes["Name"].Value);
         FillChilds(rootNode.ChildNodes, Root as MWRFileDirectory);
     }
     return Root;
 }
Example #4
0
        private ProcessResult GetDirectory()
        {
            ProcessResult pr = new ProcessResult();
            pr.ErrorCode = 3;
            try
            {
                if (!Directory.Exists(RequestedObjectPath))
                {
                    pr.ErrorDetails = "Katalog " + RequestedObjectPath + " nie istnieje";
                    return pr;
                }

                DirectoryInfo di = new DirectoryInfo(RequestedObjectPath);
                MWRFileDirectory root = new MWRFileDirectory(di.Name);
                GetObject(di, root);
                ProcessedObject = root;
                pr.ErrorCode = 0;
            }
            catch (Exception exc)
            {
                pr.ErrorDetails = exc.ToString();
            }
            return pr;
        }