private void SearchFiles(string path, string filename) { DirectoryInfo directoryInfo = new DirectoryInfo(path); FileInfo[] fileInfos = directoryInfo.GetFiles("*" + filename + "*"); DirectoryInfo[] directoryInfos = directoryInfo.GetDirectories("*" + filename + "*"); listBox.Items.Clear(); MyDirectory myDir = new MyDirectory(path); List <DiscElement> myElements = myDir.GetSubElements(); foreach (DirectoryInfo directory in directoryInfos) { foreach (DiscElement myElement in myElements) { if (directory.Name == myElement.GetName()) { DirectoryView newFolderView = new DirectoryView((MyDirectory)myElement); newFolderView.DirectoryChanged += OnDirectoryChanged; listBox.Items.Add(newFolderView); } } } foreach (FileInfo file in fileInfos) { foreach (DiscElement myElement in myElements) { if (file.Name == myElement.GetName()) { FileView newElementView = new FileView((MyFile)myElement); listBox.Items.Add(newElementView); } } } }
public bool RefreshList() { listView.ItemsSource = ""; bool isThrow = false; List <Contr> controller = new List <Contr>(); MyDirectory dirs = new MyDirectory(mainPath.Text); List <DiscElement> elements = null; try { elements = dirs.GetSubElements(); } catch { MessageBox.Show("Нет доступа"); elements = dirs.GetSubElements(); isThrow = true; } foreach (var item in elements) { controller.Add(new Contr(item)); } listView.ItemsSource = controller; CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(listView.ItemsSource); view.Filter = UserFilter; return(isThrow); }
public FileView(IDiscElement element) { InitializeComponent(); if (element is MyFile) { MyFile file = element as MyFile; this.file = file; filename.Text = file.Name; filedate.Text = file.GetCreationDate().ToString(); filesize.Text = file.Size.ToString(); filetype.Text = @"<FILE>"; filetype.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#E06C75")); } else if (element is MyDirectory) { MyDirectory directory = element as MyDirectory; this.file = directory; filename.Text = directory.Name; filedate.Text = directory.GetCreationDate().ToString(); filesize.Text = "--"; filetype.Text = @"<DIR>"; filetype.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFD19A66")); } }
public DirectoryView(MyDirectory discElement) { InitializeComponent(); this.discElement = discElement; NameBox.Text = discElement.GetName(); DateBox.Text = discElement.GetCreationTime().ToShortDateString(); }
public DirView(MyDirectory myDir) { this.myDir = myDir; InitializeComponent(); DirName.Text = myDir.Name; DirCreationTime.Text = myDir.CreationDate.ToString(); }
public DirectoryView(MyDirectory CurrentDirectory) { InitializeComponent(); this.CurrentDirectory = CurrentDirectory; DirectoryDateText.Text = CurrentDirectory.GetCreationDate; DirectoryNameText.Text = CurrentDirectory.Name; }
private void RefreshLeftList(string path, string sortType = null) { try { if (this.backStackLeft.Count == 0) { backLeft.IsEnabled = false; } else { backLeft.IsEnabled = true; } MyDirectory myDirectory = new MyDirectory(path); this.currentDirectoryLeft = myDirectory; leftList.Children.Clear(); List <DiscElement> discElementsList = myDirectory.ListDiscElements(sortType); foreach (DiscElement discElement in discElementsList) { DiscElementView discElementView = new DiscElementView(discElement); leftList.Children.Add(discElementView); discElementView.openDirectory += OpenLeftDirectory; discElementView.deleteDiscElement += DeleteDiscElementLeft; } } catch (Exception e) { MessageBox.Show(e.Message); } }
/// <summary> /// Wyszukujemy wszyskie pliki których nazwy zawieraja podany przez /// nas ciag znakow w textboxie /// </summary> private void button12_Click(object sender, RoutedEventArgs e) { MyDirectory myDirectory1 = new MyDirectory(directoryPath.Text); listOfUserControls1.Children.Clear(); List <DiscElement> subElements1 = myDirectory1.GetDiscElements(); List <DiscElement> results = subElements1.FindAll(x => x.Name.Contains(textBox.Text)); foreach (DiscElement discElement in results) { { ElementsViews discElementViews = new ElementsViews(discElement); listOfUserControls1.Children.Add(discElementViews); discElementViews.checkedChangeEv += CheckedChangeEv; } } //------------------------------------------------------------ MyDirectory myDirectory2 = new MyDirectory(directoryPath2.Text); listOfUserControls2.Children.Clear(); List <DiscElement> subElements2 = myDirectory2.GetDiscElements(); List <DiscElement> results2 = subElements2.FindAll(x => x.Name.Contains(textBox.Text)); foreach (DiscElement discElement in results2) { ElementsViews discElementViews = new ElementsViews(discElement); listOfUserControls2.Children.Add(discElementViews); discElementViews.checkedChangeEv += CheckedChangeEv; } }
public void DirectoryDeleteTest() { IEntry entry = FileFactory.CreateEntry(@"C:\ForFileManager\ToDeleteByFile1.txt"); MyDirectory.Delete(entry.FullName); Assert.IsFalse(MyDirectory.Exists(@"C:\ForFileManager\ToDeleteByFile1.txt")); }
private FileNodeItem BuildUpdateConfigFile(MyDirectory dir) { FileNodeItem item = new FileNodeItem(); item.ListWritDate = DateTime.Parse(dir.LastUpdate); item.Name = dir.Name; item.Version = dir.Version; item.IsCanSelected = false; item.ToolTip = string.Format("文件夹 日期:{0} 版本:{1}", dir.ToString(), dir.Version); foreach (FileSimpleInfo file in dir.Files) { FileNodeItem child = new FileNodeItem(); child.IsCanSelected = true; child.ListWritDate = file.ModifyDateTime; child.Name = file.Name; child.Version = file.Version; child.ToolTip = string.Format("文件 日期:{0} 版本:{1}", file.ModifyDateTime, file.Version); item.Nodes.Add(child); } foreach (MyDirectory directory in dir.Directories) { FileNodeItem child = new FileNodeItem(); item.Nodes.Add(BuildUpdateConfigFile(directory)); } return(item); }
public static string GetMyDirectory(MyDirectory directory) { var folderPath = string.Empty; switch (directory) { //case MyDirectory.PackageDir: // folderPath = GetMyDirectory(MyDirectory.Base) + PackageDirectory; // break; case MyDirectory.Project: folderPath = GetMyDirectory(MyDirectory.Base) + ProjectDirectory; break; case MyDirectory.Base: folderPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + ProgramBaseDirectory; break; } if (string.IsNullOrWhiteSpace(folderPath)) { throw new NotImplementedException("GetMyFilepath"); } if (!Directory.Exists(folderPath)) { Directory.CreateDirectory(folderPath); } return(folderPath); }
private void DisplayFiles(string path) { //Clear the listbox first FileList.Items.Clear(); //Set the current path currentPath = path; CurrentPath.Text = path; try { //Initialize FileWatcher FileSystemWatcher watcher = new FileSystemWatcher(); watcher.Path = currentPath; watcher.Changed += new FileSystemEventHandler(OnChanged); watcher.Created += new FileSystemEventHandler(OnChanged); watcher.Deleted += new FileSystemEventHandler(OnChanged); watcher.Renamed += new RenamedEventHandler(OnRenamed); watcher.EnableRaisingEvents = true; } catch (Exception e) { MessageBox.Show(e.Message); } //Create an DirectoryInfo object to extract child files from it DirectoryInfo d = new DirectoryInfo(path); MyDirectory directory = new MyDirectory(d.Name, d.FullName); currentList = directory.GetSubElements(); Iterate(directory.GetSubElements()); }
private void sortFileList(object sender, RoutedEventArgs e) { string parentPath = PanelPath(); MyDirectory myDirectory = new MyDirectory(parentPath); listOfDiscElements.Children.Clear(); List <DiscElement> allFiles = myDirectory.GetSubDiscElements(); for (int i = 1; i < allFiles.Count; ++i) { allFiles.Sort(); } foreach (DiscElement file in allFiles) { string prePath = file.Path; string postPath = prePath.Replace(parentPath + @"\", ""); DiscElementView discElementView = new DiscElementView(file); listOfDiscElements.Children.Add(discElementView); discElementView.openDiscElementClick += createFileListEventHandler; discElementView.checkedDiscElementEvent += checkedDiscElementEventHandler; } FileSystemWatcher filesystemwatcher = new FileSystemWatcher(parentPath); filesystemwatcher.Created += FileSystemWatcher_Created; filesystemwatcher.Deleted += FileSystemWatcher_Created; filesystemwatcher.Renamed += FileSystemWatcher_Created; filesystemwatcher.EnableRaisingEvents = true; }
private void searchForFile() { string parentPath = PanelPath(); string destFile = searchForFiles.Text; MyDirectory myDirectory = new MyDirectory(parentPath); listOfDiscElements.Children.Clear(); List <DiscElement> allFiles = myDirectory.GetSubDiscElements(); var filteredFiles = allFiles.Where(f => f.Name.Contains(destFile)); foreach (DiscElement file in filteredFiles) { string prePath = file.Path; DiscElementView discElementView = new DiscElementView(file); listOfDiscElements.Children.Add(discElementView); discElementView.openDiscElementClick += createFileListEventHandler; discElementView.checkedDiscElementEvent += checkedDiscElementEventHandler; discElementView.imgPopupMouseEnterEvent += imgPopupMouseEnterEventHandler; discElementView.imgPopupMouseLeaveEvent += imgPopupMouseLeaveEventHandler; discElementView.imgPopupMouseOverEvent += imgPopupMouseOverEventHandler; } FileSystemWatcher filesystemwatcher = new FileSystemWatcher(parentPath); filesystemwatcher.Created += FileSystemWatcher_Created; filesystemwatcher.Deleted += FileSystemWatcher_Created; filesystemwatcher.Renamed += FileSystemWatcher_Created; filesystemwatcher.EnableRaisingEvents = true; }
public void Binary_Serialization_Deserialization_Equal_Test(string serFileName) { MySerializer.SerializeBinary(TestCatalog.StandardDir, serFileName); _desDir = MySerializer.DeserializeFromFile(serFileName, "-bin"); File.Delete(serFileName); Assert.That(_desDir, Is.EqualTo(TestCatalog.StandardDir)); }
public WebAssignSettings() { MyDirectory = new MyDirectory(); Institution = ""; Username = WebAssignUserName.First_Name_Initial_plus_Last_Name; SEPARATOR = WebAssignSeperator.Tab; UserPassword = WebAssignPassword.LastName; }
private void bPathDownloadedArchives_Click(object sender, EventArgs e) { var path = MyDirectory.Select("directory where you want to save downloaded archives", "dir"); if (path != null) { tbDownloadedArchiveLocation.Text = path; } }
private void bPath7z_Click(object sender, EventArgs e) { var path = MyDirectory.Select("7z.exe", "7z"); if (path != null) { tbPath7z.Text = path; } }
private void bPathCheatTables_Click(object sender, EventArgs e) { var path = MyDirectory.Select("Cheat Tables", "dir"); if (path != null) { tbPathCheatTables.Text = path; } }
private void bModPath_Click(object sender, EventArgs e) { var path = MyDirectory.Select("mod", "arc/dir"); if (path != null) { tbModURL.Text = path; } }
public void LoadFiles(string path, bool sort) { if (!Directory.Exists(path)) { MessageBox.Show("Błąd Ścieżki!"); listBox.Items.Clear(); return; } MyDirectory myDir = new MyDirectory(path); List <DiscElement> myElements = myDir.GetSubElements(); listBox.Items.Clear(); if (sort == true) { myElements = myElements.OrderBy(o => o.GetCreationTime()).ToList(); List <DiscElement> myDirSorted = new List <DiscElement>(); List <DiscElement> myFileSorted = new List <DiscElement>(); foreach (DiscElement orderingElement in myElements) { if (orderingElement is MyDirectory) { myDirSorted.Add(orderingElement); } else { myFileSorted.Add(orderingElement); } } myElements.Clear(); foreach (DiscElement myDirectory in myDirSorted) { myElements.Add(myDirectory); } foreach (DiscElement myFile in myFileSorted) { myElements.Add(myFile); } } foreach (DiscElement myElement in myElements) { if (myElement is MyDirectory) { DirectoryView newFolderView = new DirectoryView((MyDirectory)myElement); newFolderView.DirectoryChanged += OnDirectoryChanged; newFolderView.DirectoryDelete += OnDeleteDirectory; listBox.Items.Add(newFolderView); } else { FileView newElementView = new FileView((MyFile)myElement); newElementView.filedelete += OnDeleteClick; listBox.Items.Add(newElementView); } } }
public void OnDirectoryChanged(object source, EventArgs e) { if (!(source is MyDirectory)) { return; } MyDirectory directory = (MyDirectory)source; LoadFiles(directory.GetPath(), false); PathBox.Text = directory.GetPath(); }
private static void DirectoryDemo() { MyDirectory myDirectory = new MyDirectory(); //myDirectory.Fun5(Path.Combine(@"D:\迅雷下载", @"ReadMe.txt"), Path.Combine(@"D:\迅雷下载", @"Copy.txt")); //Console.Read(); //string[] array = {"中国第一","美国第一"}; //myDirectory.Fun7(array); //myDirectory.Fun9(Path.Combine(@"D:\迅雷下载", "ReadMe.txt"), Path.Combine(@"D:\迅雷下载", "Compress.txt")); Console.Read(); }
private void bOpenExplorer_Click(object sender, EventArgs e) { if (Directory.Exists("mods")) { MyDirectory.OpenInFileManager("mods"); } else { bOpenExplorer.Enabled = false; } }
public static IAuditLogger <TKey, TWorkflowOptions> GetToFileAuditLogger <TKey, TWorkflowOptions>(ToFileAuditLoggerConfig config) where TKey : KeyBase where TWorkflowOptions : DecryptPlainTextEntryWorkflowOptions { Contract.Requires <ArgumentNullException>(config != null, "config"); // var myDir = new MyDirectory(); var myFile = new MyFile(); return(new ToFileAuditLogger <TKey, TWorkflowOptions>(config, myDir, myFile, new MyDateTime(), new OldLogCleaner(new ToFileAuditLoggerConfig(), myDir, myFile, new MyFileInfoFactory()))); }
public void ResharperWarning() { MyDirectory myDirectory = new MyDirectory(); IEnumerable <DataFile> allFiles = myDirectory .GetFiles(@"d:\") .Select(fileName => new DataFile(fileName)); IEnumerable <DataFile> taskFiles = allFiles .Where(file => !file.FileName.EndsWith("exe")); taskFiles.ForEach(file => { Console.WriteLine("[1] file: {0}", file.FileName); }); taskFiles.ForEach(file => { Console.WriteLine("[2] file: {0}", file); }); }
private void bIOEp2Visit_Click(object sender, EventArgs e) { var status = hiWrapper.GetInstallationStatus(GAME.Episode2); switch (status.Status) { case InstallationStatus.NotInstalled: return; case InstallationStatus.ImproperlyInstalled: return; } MyDirectory.OpenInFileManager(status.Location); }
/// <summary> /// cofanie drugiej strony /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void backPage2_Click(object sender, RoutedEventArgs e) { try { MyDirectory mydir = new MyDirectory(textBoxPathNum2.Text); RefreshListNum2(mydir.ParentDir); textBoxPathNum2.Text = mydir.ParentDir; } catch (ArgumentNullException) { RefreshListNum2(textBoxPathNum2.Text); } }
private void PreviousDirectoryButton_Click(object sender, RoutedEventArgs e) { string previouspath; previouspath = CurrentDirectory.Path.Substring(0, CurrentDirectory.Path.LastIndexOfAny(new char[] { '\\', '/' })); if (previouspath.Length < 3) { previouspath = previouspath + "\\"; } CurrentDirectory = new MyDirectory(previouspath); InvokeUpdateEvent(); ListDirectoriesAndFilesByName(); }
private void DiscComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { CurrentDirectory = new MyDirectory((DiscComboBox.SelectedItem as DriveView).GetDrive.Path); ListDirectoriesAndFilesByDate(); InvokeUpdateEvent(); } catch { MessageBox.Show("Cannot open drive"); } }