Esempio n. 1
0
        /// <summary>
        /// imports picture data from a text file with each line in the format: filename,height,width,colorindex
        /// </summary>
        public void import()
        {
            if (!File.Exists(file))
            {
                parsedirectory(dir);
                return;
            }

            string pictures;

            try
            {
                TextReader r = new StreamReader(file);
                pictures = r.ReadToEnd();
                r.Close();
            }
            catch (Exception x)
            {
                if (x.Message.Contains("used by another process"))
                {
                    if (MessageBox.Show("Please close any programs using pics.txt and press OK, or else your picture data cache will be erased", "Warning", MessageBoxButtons.OKCancel) == DialogResult.OK)
                    {
                        directory temp = new directory(dir);
                        this.pics = temp.pics;
                        this.file = temp.file;
                    }
                }
                return;
            }
            string[] picarr = pictures.Split('\n');
            foreach (string s in picarr)
            {
                string[] temp = s.Split(',');
                if (temp.Length > 3)
                {
                    pics.Add(new picture(temp[0], int.Parse(temp[1]), int.Parse(temp[2]), temp[3].Trim()));
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// imports picture data from a text file with each line in the format: filename,height,width,colorindex
        /// </summary>
        public void import()
        {
            if (!File.Exists(file))
            {
                parsedirectory(dir);
                return;
            }

            string pictures;
            try
            {
                TextReader r = new StreamReader(file);
                pictures = r.ReadToEnd();
                r.Close();
            }
            catch (Exception x)
            {
                if (x.Message.Contains("used by another process"))
                    if (MessageBox.Show("Please close any programs using pics.txt and press OK, or else your picture data cache will be erased", "Warning", MessageBoxButtons.OKCancel) == DialogResult.OK)
                    {
                        directory temp = new directory(dir);
                        this.pics = temp.pics;
                        this.file = temp.file;
                    }
                return;
            }
            string[] picarr = pictures.Split('\n');
            foreach (string s in picarr)
            {
                string[] temp = s.Split(',');
                if (temp.Length > 3)
                    pics.Add(new picture(temp[0], int.Parse(temp[1]), int.Parse(temp[2]), temp[3].Trim()));
            }
        }