Example #1
0
        /// <summary>
        /// Parse the online repository and create athe online file list
        /// </summary>
        private void BuildOnlineFile()
        {
            if (File.Exists(Settings.FileList_Online))
            {
                return;
            }

            WallpaperList tmpList = null;

            try
            {
                tmpList = new WallpaperList(Settings.FileList_Online, false);

                string[] files = Directory.GetFiles(Settings.OnlineDatabaseFolder);
                foreach (string file in files)
                {
                    using (Stream fileStream = File.Open(file, FileMode.Open))
                    {
                        using (StreamReader fileReader = new StreamReader(fileStream))
                        {
                            while (true)
                            {
                                string line = fileReader.ReadLine();
                                if (line == null)
                                {
                                    break;
                                }

                                if (line.StartsWith("#"))
                                {
                                    continue;
                                }

                                string filePath            = null;
                                int    firstDelimiterIndex = line.IndexOf('|');
                                if (firstDelimiterIndex != -1)
                                {
                                    filePath = line.Substring(0, firstDelimiterIndex);
                                }

                                if (string.IsNullOrEmpty(filePath))
                                {
                                    continue;
                                }

                                string dimensions           = null;
                                int    secondDelimiterIndex = line.IndexOf('^', firstDelimiterIndex);
                                if (secondDelimiterIndex != -1)
                                {
                                    dimensions = line.Substring(firstDelimiterIndex + 1, secondDelimiterIndex - firstDelimiterIndex - 1);
                                }

                                string thumbnail = null;
                                if ((secondDelimiterIndex < line.Length))
                                {
                                    thumbnail = line.Substring(secondDelimiterIndex + 1);
                                }

                                if (string.IsNullOrEmpty(thumbnail))
                                {
                                    thumbnail = filePath;
                                }

                                tmpList.AddFile(filePath, thumbnail, dimensions);
                            }
                        }
                    }
                }
            }
            finally
            {
                if (tmpList != null)
                {
                    tmpList.SaveToFile();
                }
            }
        }