示例#1
0
        private void ImportFileNames(string[] FileNames)
        {
            string ParentPath = Path.GetDirectoryName(FileNames.First());

            foreach (string str in FileNames)
            {
                if ((Path.GetFileNameWithoutExtension(str) == " " || Directory.Exists(str)) && System.IO.Directory.Exists(System.IO.Path.GetDirectoryName(str)))
                {
                    string folderpath = System.IO.Path.GetDirectoryName(str);
                    App.Settings.FileConvert.GetExtentionArray(Combobox_Filter.Text).ForEach(filter =>
                    {
                        List <string> childFileList = System.IO.Directory.GetFiles(folderpath, filter.Trim(), AccordingToChild ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly).Where(x => App.Settings.FileConvert.CheckExtension(x, filter)).ToList();
                        childFileList.ForEach(x =>
                        {
                            FileListTemp.Add(new FileList_Line()
                            {
                                IsChecked = true, IsFile = true, Name = System.IO.Path.GetFileName(x), ParentPath = ParentPath, Path = Path.GetDirectoryName(x)
                            });
                        });
                    });
                    FileListTemp = new ObservableCollection <FileList_Line>(FileListTemp.OrderBy(x => x.Name).Distinct().OrderBy(x => x.IsFile).OrderBy(x => x.Path));
                }
                else if (File.Exists(str))
                {
                    FileListTemp.Add(new FileList_Line()
                    {
                        IsChecked = true, Name = Path.GetFileName(str), ParentPath = ParentPath, Path = Path.GetDirectoryName(str)
                    });
                }
            }
        }