private void dataGridView1_SelectionChanged(object sender, EventArgs e) { _checked_items = FsType.fsFile; _checked.Clear(); foreach (DataGridViewRow row in (sender as SynoReportDataGridView).SelectedRows) { var d = row.DataBoundItem as DuplicateFileInfo; _checked.Add(d.FullPath.Substring(1)); } }
public FileZip(string zipPath, FsType fsType = FsType.Local) : base(zipPath, fsType) { IFile file = new File(zipPath); if (!file.Exists) { ZipFile.CreateFromDirectory(file.Directory.FullName, file.Name); } _archive = new ZipArchive(Open(), ZipArchiveMode.Update, false); }
private void Where_BeforeCheck(object sender, TreeViewCancelEventArgs e) { bool location; bool file; bool isFile; bool expected = false; var path = GetUNCPath(e.Node, out location, out file, out isFile); System.Diagnostics.Debug.WriteLine(string.Format("tested {0}", path == null ? "ACCESS DENIED" : path.FullName)); System.Diagnostics.Debug.WriteLine(string.Format("type of selection {0}, {1} item(s) in selection", _checked_items, _checked.Count)); if (path != null) { if (!e.Node.Checked) { if (_checked.Count == 0) { _checked_items = isFile ? FsType.fsFile : FsType.fsFolder; } System.Diagnostics.Debug.WriteLine(string.Format("type of selection {0}, {1} item(s) in selection", _checked_items, _checked.Count)); if (_checked_items == (isFile ? FsType.fsFile : FsType.fsFolder)) { if (!_checked.Contains(path.FullName)) { _checked.Add(path.FullName); expected = true; } } } else { if (_checked_items == (isFile ? FsType.fsFile : FsType.fsFolder)) { if (_checked.Contains(path.FullName)) { _checked.Remove(path.FullName); expected = true; } } } } e.Cancel = !expected; System.Diagnostics.Debug.WriteLine(string.Format("{0} {1}", System.DateTime.UtcNow.Ticks, expected ? "approved" : "canceled")); System.Diagnostics.Debug.WriteLine(string.Format("type of selection {0}, {1} item(s) in selection", _checked_items, _checked.Count)); }
public static bool Is(FsType type, FileSystemInfo path) { switch (type) { case FsType.Dir: return(path is DirectoryInfo); case FsType.File: return(path is FileInfo); default: throw new ArgumentOutOfRangeException(nameof(type), type, null); } }
/// <summary> /// Returns whether this font is licensed under a freely redistributable license. Currently /// this is a best-effort method, as the copyright string (and name) don't always give us /// a clear picture. /// </summary> /// <param name="fontFullName"></param> /// <returns></returns> public static bool IsFreeFont(string fontFullName) { try { FsType myType = GetFsType(fontFullName); if (myType != FsType.Restricted && myType != FsType.PreviewPrint) { return(true); } } catch (Exception) { return(false); } return(false); }
private string EvaluatePath(string filePath, FsType fsType) { switch (fsType) { case FsType.Local: if (Path.IsPathRooted(filePath)) { throw new Exception("File path: " + filePath + " is Absolute, but given the FsType of Local!"); } return(filePath); case FsType.Absolute: if (Path.IsPathRooted(filePath)) { throw new Exception("File path: " + filePath + " is Relative or External, but given the FsType of Absolute!"); } return(filePath); } return(string.Empty); }
internal Directory(DirectoryInfo directoryInfo, FsType fsType) { _evaluatedPath = EvaluatePath(directoryInfo.Name, fsType); _info = directoryInfo; Type = fsType; }
public Directory(string directoryPath, FsType fsType = FsType.Local) { _evaluatedPath = EvaluatePath(directoryPath, fsType); _info = new DirectoryInfo(_evaluatedPath); Type = fsType; }
internal File(FileInfo fileInfo, FsType fsType) { _evaluatedPath = EvaluatePath(fileInfo.FullName, fsType); _info = new FileInfo(_evaluatedPath); Type = fsType; }
public File(string filePath, FsType fsType = FsType.Local) { _evaluatedPath = EvaluatePath(filePath, fsType); _info = new FileInfo(_evaluatedPath); Type = fsType; }