public MyDiskInfo DiskSpaces(string diskName) { MyDiskInfo mdi; if (Directory.GetLogicalDrives().Contains(String.Format("{0}:\\", diskName.ToUpper()))) { DriveInfo di = new DriveInfo(diskName); mdi = new MyDiskInfo() { DiskName=di.Name, FreeSpace = di.TotalFreeSpace, TotalSpace = di.TotalSize, DiskType = di.DriveType }; } else { mdi = new MyDiskInfo() { DiskName = "notAvailable", FreeSpace = -1, TotalSpace = -1, DiskType = DriveType.Unknown }; } return mdi; }
public MyDiskInfo DiskSpaces(string diskName) { MyDiskInfo mdi; if (Directory.GetLogicalDrives().Contains(String.Format("{0}:\\", diskName.ToUpper()))) { DriveInfo di = new DriveInfo(diskName); mdi = new MyDiskInfo() { DiskName = di.Name, FreeSpace = di.TotalFreeSpace, TotalSpace = di.TotalSize, DiskType = di.DriveType }; } else { mdi = new MyDiskInfo() { DiskName = "notAvailable", FreeSpace = -1, TotalSpace = -1, DiskType = DriveType.Unknown }; } return(mdi); }
public MyDiskInfo DiskSpaces(string diskName) { MyDiskInfo mdi; if (Directory.GetLogicalDrives().Contains(String.Format("{0}:\\", diskName.ToUpper()))) { DriveInfo di = new DriveInfo(diskName); mdi = new MyDiskInfo() { DiskName = di.Name, FreeSpace = String.Format("{0:0.00} GB", (double)di.TotalFreeSpace / 1024 / 1024 / 1024), AvailableFreeSpace = String.Format("{0:0.00} GB", (double)di.AvailableFreeSpace / 1024 / 1024 / 1024), TotalSpace = String.Format("{0:0.00} GB", (double)di.TotalSize / 1024 / 1024 / 1024), DiskType = di.DriveType }; mdi.user = new User() { Login = System.Security.Principal.WindowsIdentity.GetCurrent().Name, Date = DateTime.Now, type = UserType.Student }; } else { mdi = new MyDiskInfo() { user = new User() { Login = System.Security.Principal.WindowsIdentity.GetCurrent().Name, Date = DateTime.Now, type = UserType.Unknown } }; } return mdi; }
public MyDiskInfo DiskSpaces(string diskName) { MyDiskInfo mdi; if (Directory.GetLogicalDrives().Contains(String.Format("{0}:\\", diskName.ToUpper()))) { DriveInfo di = new DriveInfo(diskName); mdi = new MyDiskInfo() { DiskName = di.Name, FreeSpace = String.Format("{0:0.00} GB", (double)di.TotalFreeSpace / 1024 / 1024 / 1024), AvailableFreeSpace = String.Format("{0:0.00} GB", (double)di.AvailableFreeSpace / 1024 / 1024 / 1024), TotalSpace = String.Format("{0:0.00} GB", (double)di.TotalSize / 1024 / 1024 / 1024), DiskType = di.DriveType }; mdi.user = new User() { Login = System.Security.Principal.WindowsIdentity.GetCurrent().Name, Date = DateTime.Now, type = UserType.Student }; } else { mdi = new MyDiskInfo() { user = new User() { Login = System.Security.Principal.WindowsIdentity.GetCurrent().Name, Date = DateTime.Now, type = UserType.Unknown } }; } return(mdi); }