Esempio n. 1
0
        public virtual string LoadFileListAllTree(bool sortFileList = true)
        {
            string retVal = string.Empty;

            if (Directory.Exists(FileSelParm.SourceFileFolder))
            {
                AllFile.Clear();
                _dicRecordDate.Clear();
                List <string> filterList   = FileSelParm.FileFilter.ToUpper().Split('|').ToList();
                bool          havAllFilter = filterList.Contains("*");
                bool          typeIgnore   = FileSelParm.FileTypeIsIgnore;
                DirectoryInfo dicInfo      = new DirectoryInfo(FileSelParm.SourceFileFolder);

                this.LoadFileListAllTree(dicInfo, filterList, havAllFilter, typeIgnore);

                //排序
                if (sortFileList)
                {
                    this.SortFileList();
                }

                //一行一行显示文件名
                retVal = CommFunction.StringList2String(AllFile.Select(f => f.FullName).ToList());
            }
            else
            {
                CommFunction.WriteMessage("文件夹不存在!");
            }

            return(retVal);
        }
Esempio n. 2
0
        public virtual string LoadFileList(bool sortFileList = true)
        {
            string retVal = string.Empty;

            if (Directory.Exists(FileSelParm.SourceFileFolder))
            {
                AllFile.Clear();
                _dicRecordDate.Clear();
                List <string> filterList   = FileSelParm.FileFilter.ToUpper().Split('|').ToList();
                bool          havAllFilter = filterList.Contains("*");
                bool          typeIgnore   = FileSelParm.FileTypeIsIgnore;
                DirectoryInfo dicInfo      = new DirectoryInfo(FileSelParm.SourceFileFolder);
                List <string> chgFileList  = FileSelParm.UseSpecFileList ? FileSelParm.SpecFileList.ToUpper().Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).ToList() : null;

                foreach (FileInfo fileInfo in dicInfo.GetFiles())
                {
                    //隐藏文件和系统文件就不要过来凑热闹了
                    if ( /*( fileInfo.Attributes & FileAttributes.Hidden ) == FileAttributes.Hidden || */
                        (fileInfo.Attributes & FileAttributes.System) == FileAttributes.System)
                    {
                        continue;
                    }

                    if (FileSelParm.UseSpecFileList)
                    {
                        if (chgFileList != null && chgFileList.Contains(fileInfo.Name.ToUpper()))
                        {
                            AllFile.Add(fileInfo);
                        }
                    }
                    else
                    {
                        if (havAllFilter && !typeIgnore)
                        {
                            AllFile.Add(fileInfo);
                        }
                        else
                        {
                            string strExt = fileInfo.Extension.Length > 0 ? fileInfo.Extension.Remove(0, 1).ToUpper() : "";
                            //符合异或条件
                            if (typeIgnore ^ filterList.Contains(strExt))
                            {
                                AllFile.Add(fileInfo);
                            }
                        }
                    }
                }

                //排序
                if (sortFileList)
                {
                    this.SortFileList();
                }

                //一行一行显示文件名
                retVal = CommFunction.StringList2String(AllFile.Select(f => f.FullName).ToList());
            }
            else
            {
                CommFunction.WriteMessage("文件夹不存在!");
            }

            return(retVal);
        }