private void set_readonly(string file_name) { FileSystemInfo fsi = IOhelper.GetFileSystemInfo(file_name); FileAttributes fa_existing = fsi.Attributes; FileAttributes fa_needed = FileAttributes.ReadOnly | fa_existing; fsi.Attributes = fa_needed; }
private void clear_readonly(string file_name) { FileSystemInfo fsi = IOhelper.GetFileSystemInfo(file_name); FileAttributes fa_existing = fsi.Attributes; FileAttributes fs_feeded = ~((~fa_existing) | FileAttributes.ReadOnly); fsi.Attributes = fs_feeded; }
private void set_attributes_file(string file_name, FileAttributes fa) { FileSystemInfo fsi = IOhelper.GetFileSystemInfo(file_name); if (fsi == null) { throw new ApplicationException(string.Format(Options.GetLiteral(Options.LANG_FILE_0_NOT_FOUND), file_name)); } fsi.Attributes = fa; }
private void set_attributes_file(string file_name, FileAttributes fa) { FileSystemInfo fsi = IOhelper.GetFileSystemInfo(file_name); if (fsi == null) { throw new ApplicationException(string.Format("File '{0}' not found.", file_name)); } fsi.Attributes = fa; }
private void add_attributes_file(string file_name, FileAttributes fa) { FileSystemInfo fsi = IOhelper.GetFileSystemInfo(file_name); if (fsi == null) { throw new ApplicationException(string.Format(Options.GetLiteral(Options.LANG_FILE_0_NOT_FOUND), file_name)); } FileAttributes existing_fa = fsi.Attributes; FileAttributes needed_fa = fa | existing_fa; fsi.Attributes = needed_fa; }
private void add_attributes_file(string file_name, FileAttributes fa) { FileSystemInfo fsi = IOhelper.GetFileSystemInfo(file_name); if (fsi == null) { throw new ApplicationException(string.Format("File '{0}' not found")); } FileAttributes existing_fa = fsi.Attributes; FileAttributes needed_fa = fa | existing_fa; fsi.Attributes = needed_fa; }
private void clear_attributes_file(string file_name, FileAttributes fa) { FileSystemInfo fsi = IOhelper.GetFileSystemInfo(file_name); if (fsi == null) { throw new ApplicationException(string.Format(Options.GetLiteral(Options.LANG_FILE_0_NOT_FOUND), file_name)); } FileAttributes existing_fa = fsi.Attributes; int existing_fa_int = (int)existing_fa; int needed_fa_int; int fa_int = (int)fa; needed_fa_int = ~((~existing_fa_int) | fa_int); FileAttributes needed_fa = (FileAttributes)needed_fa_int; fsi.Attributes = needed_fa; }
private void clear_attributes_file(string file_name, FileAttributes fa) { FileSystemInfo fsi = IOhelper.GetFileSystemInfo(file_name); if (fsi == null) { throw new ApplicationException(string.Format("File '{0}' not found")); } FileAttributes existing_fa = fsi.Attributes; int existing_fa_int = (int)existing_fa; int needed_fa_int; int fa_int = (int)fa; needed_fa_int = ~((~existing_fa_int) | fa_int); FileAttributes needed_fa = (FileAttributes)needed_fa_int; fsi.Attributes = needed_fa; }
protected override void internal_command_proc() { try { var e = new QueryPanelInfoEventArgs(); OnQueryCurrentPanel(e); if (e.FocusedIndex == -1) { return; } var target_file = string.Empty; var dl = (DirectoryList)e.ItemCollection; var sel_indices = e.SelectedIndices; var group_mode = (sel_indices.Length > 1); //we need cache list of selected files //becouse e.ItemCollection can change while processing (sort!) var sel_names = new List <string>(); for (var i = 0; i < sel_indices.Length; i++) { sel_names.Add(e.ItemCollection.GetItemDisplayNameLong(sel_indices[i])); } if (!group_mode) { if (sel_indices.Length == 1) { target_file = Path.Combine(dl.DirectoryPath, dl.GetItemDisplayNameLong(sel_indices[0])); } else { target_file = Path.Combine(dl.DirectoryPath, dl.GetItemDisplayNameLong(e.FocusedIndex)); } } if (target_file.EndsWith("..")) { target_file = dl.DirectoryPath + Path.DirectorySeparatorChar; } FileSystemInfo target_fsi = null; if (!group_mode) { target_fsi = IOhelper.GetFileSystemInfo(target_file); } var dialog = new TouchFileDialog(); dialog.Text = Options.GetLiteral(Options.LANG_TOUCH); if (!group_mode) { dialog.textBoxFileName.Text = target_file; dialog.dateTimePickerAccess.Value = target_fsi.LastAccessTime; dialog.dateTimePickerCreation.Value = target_fsi.CreationTime; dialog.dateTimePickerModification.Value = target_fsi.LastWriteTime; } else { dialog.textBoxFileName.Text = string.Format("{0} " + Options.GetLiteral(Options.LANG_ENTRIES), sel_indices.Length); dialog.textBoxFileName.Enabled = false; } if (dialog.ShowDialog() != DialogResult.OK) { return; } if (!group_mode) { if (dialog.textBoxFileName.Text != target_file) { //try create new file netCommander.FileSystemEx.WinAPiFSwrapper.CreateNewEmptyFile(dialog.textBoxFileName.Text); //if success target_fsi = new FileInfo(dialog.textBoxFileName.Text); } } //set times if (group_mode) { foreach (var one_name in sel_names) { try { target_file = Path.Combine(dl.DirectoryPath, one_name); target_fsi = IOhelper.GetFileSystemInfo(target_file); if (dialog.dateTimePickerAccess.Checked) { target_fsi.LastAccessTime = dialog.dateTimePickerAccess.Value; } if (dialog.dateTimePickerCreation.Checked) { target_fsi.CreationTime = dialog.dateTimePickerCreation.Value; } if (dialog.dateTimePickerModification.Checked) { target_fsi.LastWriteTime = dialog.dateTimePickerModification.Value; } OnItemProcessDone(new ItemEventArs(one_name)); } catch (Exception ex) { Messages.ShowException(ex); } } } else { try { if (dialog.dateTimePickerAccess.Checked) { target_fsi.LastAccessTime = dialog.dateTimePickerAccess.Value; } if (dialog.dateTimePickerCreation.Checked) { target_fsi.CreationTime = dialog.dateTimePickerCreation.Value; } if (dialog.dateTimePickerModification.Checked) { target_fsi.LastWriteTime = dialog.dateTimePickerModification.Value; } } catch (Exception ex) { Messages.ShowException(ex); } } } catch (Exception ex) { Messages.ShowException(ex); } } // end of proc