Exemple #1
0
        public void load_file(string aPath)//选择文件
        {
            StreamReader sr = File.OpenText(aPath);
            string       s  = "";

            while ((s = sr.ReadLine()) != null)
            {
                s = s.Trim();

                if (!s.StartsWith("//") && !Regex.IsMatch(s, @"^[\s]*$"))
                {
                    FileName.Add(s);
                }
            }
            FileNum = FileName.Count();
        }
Exemple #2
0
        public void load_folder(string aPath)//选择文件夹
        {
            DirectoryInfo dir = new DirectoryInfo(aPath);

            FileInfo[]      files = dir.GetFiles();       //目录下文件
            DirectoryInfo[] dii   = dir.GetDirectories(); //目录下子文件夹

            foreach (FileInfo info in files)
            {
                if (Regex.IsMatch(info.Name, @".*\.v$") || Regex.IsMatch(info.Name, @".*\.vhd$"))
                {
                    FileName.Add(info.FullName);
                }
            }

            foreach (DirectoryInfo d in dii)
            {
                load_folder(d.FullName);
            }
            FileNum = FileName.Count();
        }
        public void ReadImage(string finename)
        {
            using (BinaryReader loader = new BinaryReader(File.Open(finename, FileMode.Open, FileAccess.Read)))
            {
                FileInfo fd     = new FileInfo(finename);
                int      Length = (int)fd.Length;
                byte[]   buf    = new byte[Length];
                buf = loader.ReadBytes((int)fd.Length);

                loader.Close();
                BitmapImage btm = new BitmapImage();
                btm.BeginInit();
                btm.CacheOption  = BitmapCacheOption.OnLoad;
                btm.StreamSource = new MemoryStream(buf);
                btm.EndInit();
                btm.Freeze();
                FileName.Add(fd.Name);
                ImageList.Add(btm);
                GC.Collect();
            }
        }