public static string GetDisksInfo() { try { DriveInfo[] drivers = DriveInfo.GetDrives(); string info = $"Count of drivers: {DriveInfo.GetDrives().Length}\n"; foreach (var driveInfo in drivers) { try { info += $"Name: {driveInfo.Name} Free space: {driveInfo.AvailableFreeSpace / 1073741824} " + $"GB Total space: {driveInfo.TotalSize / 1073741824} GB " + $"Label: {driveInfo.VolumeLabel}\n"; DVVLog.AddNote("DVDDiskInfo", driveInfo.Name); //add log note } catch (IOException) { info += $"{driveInfo} not available.\n"; } } return(info); } catch (DriveNotFoundException) { return("Drive not found"); } }
public static string GetChild(string directoryPath) { try { DirectoryInfo info = new DirectoryInfo(directoryPath); DVVLog.AddNote("DVVDirInfo", info.FullName); return(Directory.GetDirectories(directoryPath).Count().ToString()); } catch (DirectoryNotFoundException) { return("Directory not found"); } }
public static string GetParents(string directoryPath) { try { DirectoryInfo info = new DirectoryInfo(directoryPath); DVVLog.AddNote("DVVDirInfo", info.FullName); //add log note return(info.Parent.ToString()); } catch (DirectoryNotFoundException) { return("Directory not found"); } }
public static string GetFileSystem(string diskName) { try { DriveInfo driveInfo = new DriveInfo(diskName); DVVLog.AddNote("DVDDiskInfo", driveInfo.Name); //add log note return(driveInfo.DriveFormat); } catch (DriveNotFoundException) { return("Drive not found"); } }
public static string GetFreeSpace(string diskName) { try { DriveInfo driveInfo = new DriveInfo(diskName); DVVLog.AddNote("DVVDiskInfo", driveInfo.Name); //add log return((driveInfo.AvailableFreeSpace / 1073741824).ToString()); } catch (DriveNotFoundException) { return("Drive not found"); } }
public static string GetCreationTime(string filename) { try { FileInfo file = new FileInfo(filename); DVVLog.AddNote("DVVFileInfo", file.FullName); //add log note return($"Creation time: {file.CreationTime}"); } catch (FileNotFoundException) { return("File not found"); throw; } }
public static string GetMainFileInfo(string filename) { try { FileInfo file = new FileInfo(filename); DVVLog.AddNote("DVVFileInfo", file.FullName); //add log note return($"File name: {file.Name} extension: {file.Extension} size: " + $"{file.Length / 1024} kb."); } catch (FileNotFoundException) { return("File not found"); throw; } }