Example #1
0
        /// <summary>
        /// 文件过滤
        /// </summary>
        /// <param name="info"></param>
        public void FileFilter(FileSystemInfo info)
        {
            //var info = new DirectoryInfo(ChiocePath);
            if (!info.Exists)
            {
                return;
            }

            var dir = info as DirectoryInfo;

            //不是目录
            if (dir == null)
            {
                return;
            }

            var files = dir.GetFileSystemInfos();

            for (int i = 0; i < files.Length; i++)
            {
                FileInfo file = files[i] as FileInfo;
                //是文件
                if (file != null)
                {
                    if (!file.Name.Contains("."))
                    {
                        continue;
                    }
                    var b = IsContainsType(file.Name);
                    if (b)
                    {
                        string fileEncoding = EncodePelaceHelper.GetEncoding(file.FullName);
                        if (fileEncoding.ToUpper().IndexOf("UTF".ToUpper()) < 0)
                        {
                            gv_data.Rows.Add(Count, fileEncoding, file.FullName.ToString().Substring(ChiocePath.Length));
                            Count++;
                        }
                    }
                }
                //对于子目录,进行递归调用
                else
                {
                    FileFilter(files[i]);
                }
            }
        }
Example #2
0
        /// <summary>
        /// 文件过滤
        /// </summary>
        /// <param name="info"></param>
        public void FileFilter(String path)
        {
            var di = path.AsDirectory();

            if (!di.Exists)
            {
                return;
            }

            var Count = 1;

            foreach (var file in di.GetAllFiles(txtSuffix.Text, true))
            {
                var enc = EncodePelaceHelper.GetEncoding(file.FullName);
                if (enc != null && !enc.WebName.EqualIgnoreCase(ddlEncodes.Text))
                {
                    gv_data.Rows.Add(Count++, enc.WebName, file.FullName.Substring(path.Length));
                }
            }
        }