Exemplo n.º 1
0
        public bool AddFilesToListView(ListView aListview)
        {
            myFiles.Clear();
            CommonOpenFileDialog openFileDlg = new CommonOpenFileDialog();

            openFileDlg.InitialDirectory = "C:\\";
            openFileDlg.IsFolderPicker   = true;
            openFileDlg.Multiselect      = true;
            // Launch OpenFileDialog by calling ShowDialog method

            // Get the selected file name and display in a TextBox.
            // Load content of file in a TextBlock

            if (openFileDlg.ShowDialog() == CommonFileDialogResult.Ok)
            {
                FileInfo[] info = GetFilesAsFileInfo(openFileDlg.FileName);

                foreach (var item in info)
                {
                    ListFile listFile = new ListFile();
                    listFile.Name     = item.Name;
                    listFile.Type     = item.Extension.Trim('.');
                    listFile.Size     = item.Length;
                    listFile.FullPath = item.DirectoryName;
                    myFiles.Add(listFile);
                }
                aListview.ItemsSource = myFiles;
                return(true);
            }
            return(false);
        }
        private void OpenFildeMenuItemClick(object sender, RoutedEventArgs e)
        {
            ListFile file = FileslistView.SelectedItem as ListFile;

            myFileFinder.OpenFileThroughPath(file.FullPath + "\\" + file.Name, file.Name);
        }
        private void OpenFolderMenuItemClick(object sender, RoutedEventArgs e)
        {
            ListFile file = FileslistView.SelectedItem as ListFile;

            myFileFinder.OpenFolderThroughPath(file.FullPath);
        }