Пример #1
0
        public static string GetDisksInfo()
        {
            try
            {
                DriveInfo[] drivers = DriveInfo.GetDrives();
                string      info    = $"Number 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";

                        LVILog.AddNote("LVIDiskInfo", driveInfo.Name);   //add log note
                    }
                    catch (IOException)
                    {
                        info += $"{driveInfo} not available.\n";
                    }
                }

                return(info);
            }
            catch (DriveNotFoundException)
            {
                return("Drive not found");
            }
        }
Пример #2
0
 public static string GetFreeSpace(string diskName)
 {
     try
     {
         DriveInfo driveInfo = new DriveInfo(diskName);
         LVILog.AddNote("LVIDiskInfo", driveInfo.Name);   //add log
         return((driveInfo.AvailableFreeSpace / 1073741824).ToString());
     }
     catch (DriveNotFoundException)
     {
         return("Drive not found");
     }
 }
Пример #3
0
 public static string GetFileSystem(string diskName)
 {
     try
     {
         DriveInfo driveInfo = new DriveInfo(diskName);
         LVILog.AddNote("LVIDiskInfo", driveInfo.Name);   //add log note
         return(driveInfo.DriveFormat);
     }
     catch (DriveNotFoundException)
     {
         return("Drive not found");
     }
 }
Пример #4
0
 public static string GetParents(string directoryPath)
 {
     try
     {
         DirectoryInfo info = new DirectoryInfo(directoryPath);
         LVILog.AddNote("LVIDirInfo", info.FullName);   //add log note
         return(info.Parent.ToString());
     }
     catch (DirectoryNotFoundException)
     {
         return("Directory not found");
     }
 }
Пример #5
0
        public static string GetCreationTime(string filename)
        {
            try
            {
                FileInfo file = new FileInfo(filename);
                LVILog.AddNote("LVIFileInfo", file.FullName);   //add log note
                return($"Creation time: {file.CreationTime}");
            }
            catch (FileNotFoundException)
            {
                return("File not found");

                throw;
            }
        }
Пример #6
0
        public static string GetMainFileInfo(string filename)
        {
            try
            {
                FileInfo file = new FileInfo(filename);
                LVILog.AddNote("LVIFileInfo", 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;
            }
        }