Beispiel #1
0
        /// <summary>
        /// Load the info of the pending downloads from the file of the pending downloads.
        /// </summary>
        public static void LoadPendingDownloadsInfo()
        {
            XmlDocument XmlDoc = new XmlDocument();

            string xmlFilePath = Global.iKiwiPath + "PendingDownloads.xml";

            if (File.Exists(xmlFilePath))
            {
                // read the file
                try
                {
                    XmlDoc.Load(xmlFilePath);

                    XmlNode node = XmlDoc.SelectSingleNode("PENDING_DOWNLOADS");

                    if (node != null)
                    {
                        for (int i = 0; i < node.ChildNodes.Count; i++)
                        {
                            string   name      = string.Empty;
                            int      size      = 0;
                            BitArray filePacks = new BitArray(0);

                            for (int n = 0; n < node.ChildNodes[i].ChildNodes.Count; n++)
                            {
                                XmlNode node2 = node.ChildNodes[i].ChildNodes[n];

                                switch (node2.Name)
                                {
                                case "NAME":
                                {
                                    name = node2.InnerText;
                                    break;
                                }

                                case "SIZE":
                                {
                                    size = int.Parse(node2.InnerText);
                                    break;
                                }

                                case "FILE_PACKS":
                                {
                                    BitArray ba = Utilities.Converterer.ConvertHexToBit(node2.InnerText);

                                    if (size % 16384 == 0)
                                    {
                                        filePacks = new BitArray(size / 16384);
                                    }
                                    else
                                    {
                                        filePacks = new BitArray((size / 16384) + 1);
                                    }

                                    for (int a = 0; a < filePacks.Length; a++)
                                    {
                                        filePacks[a] = ba[a];
                                    }

                                    break;
                                }

                                default:
                                {
                                    break;
                                }
                                }
                            }

                            Objects.Download download = new iKiwi.Objects.Download(name, size, node.ChildNodes[i].Name.Substring(1), filePacks);

                            Daemons.Downloader.AddDownload(download);
                        }
                    }
                }
                catch
                {
                    try
                    {
                        // delete the corrupted file
                        File.Delete(xmlFilePath);
                    }
                    catch
                    {
                    }
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Load the info of the pending downloads from the file of the pending downloads.
        /// </summary>
        public static void LoadPendingDownloadsInfo()
        {
            XmlDocument XmlDoc = new XmlDocument();

            string xmlFilePath = Global.iKiwiPath + "PendingDownloads.xml";

            if(File.Exists(xmlFilePath))
            {
                // read the file
                try
                {
                    XmlDoc.Load(xmlFilePath);

                    XmlNode node = XmlDoc.SelectSingleNode("PENDING_DOWNLOADS");

                    if (node != null)
                    {
                        for (int i = 0; i < node.ChildNodes.Count; i++)
                        {
                            string name = string.Empty;
                            int size = 0;
                            BitArray filePacks  = new BitArray(0);

                            for (int n = 0; n < node.ChildNodes[i].ChildNodes.Count; n++)
                            {
                                XmlNode node2 = node.ChildNodes[i].ChildNodes[n];

                                switch(node2.Name)
                                {
                                    case "NAME":
                                        {
                                            name = node2.InnerText;
                                            break;
                                        }
                                    case "SIZE":
                                        {
                                            size = int.Parse(node2.InnerText);
                                            break;
                                        }
                                    case "FILE_PACKS":
                                        {
                                            BitArray ba = Utilities.Converterer.ConvertHexToBit(node2.InnerText);

                                            if (size % 16384 == 0)
                                            {
                                                filePacks = new BitArray(size / 16384);
                                            }
                                            else
                                            {
                                                filePacks = new BitArray((size / 16384) + 1);
                                            }

                                            for (int a = 0; a < filePacks.Length; a++)
                                            {
                                                filePacks[a] = ba[a];
                                            }

                                            break;
                                        }
                                    default:
                                        {
                                            break;
                                        }
                                }
                            }

                            Objects.Download download = new iKiwi.Objects.Download(name, size, node.ChildNodes[i].Name.Substring(1), filePacks);

                            Daemons.Downloader.AddDownload(download);
                        }
                    }
                }
                catch
                {
                    try
                    {
                        // delete the corrupted file
                        File.Delete(xmlFilePath);
                    }
                    catch
                    {
                    }
                }
            }
        }