예제 #1
0
        private IEnumerable <DiskSpace> GetDiskSpace(IEnumerable <String> paths)
        {
            foreach (var path in paths)
            {
                DiskSpace diskSpace = null;

                try
                {
                    var freeSpace  = _diskProvider.GetAvailableSpace(path).Value;
                    var totalSpace = _diskProvider.GetTotalSize(path).Value;

                    diskSpace = new DiskSpace
                    {
                        Path       = path,
                        FreeSpace  = freeSpace,
                        TotalSpace = totalSpace
                    };

                    diskSpace.Label = _diskProvider.GetVolumeLabel(path);
                }
                catch (Exception ex)
                {
                    _logger.WarnException("Unable to get free space for: " + path, ex);
                }

                if (diskSpace != null)
                {
                    yield return(diskSpace);
                }
            }
        }
예제 #2
0
        private IEnumerable<DiskSpace> GetDiskSpace(IEnumerable<String> paths)
        {
            foreach (var path in paths)
            {
                DiskSpace diskSpace = null;

                try
                {
                    var freeSpace = _diskProvider.GetAvailableSpace(path).Value;
                    var totalSpace = _diskProvider.GetTotalSize(path).Value;

                    diskSpace = new DiskSpace
                                {
                                    Path = path,
                                    FreeSpace = freeSpace,
                                    TotalSpace = totalSpace
                                };

                    diskSpace.Label = _diskProvider.GetVolumeLabel(path);
                }
                catch (Exception ex)
                {
                    _logger.WarnException("Unable to get free space for: " + path, ex);
                }

                if (diskSpace != null)
                {
                    yield return diskSpace;
                }
            }
        }
예제 #3
0
        private IEnumerable <DiskSpace> GetDiskSpace(IEnumerable <string> paths, bool suppressWarnings = false)
        {
            foreach (var path in paths)
            {
                DiskSpace diskSpace = null;

                try
                {
                    var freeSpace  = _diskProvider.GetAvailableSpace(path);
                    var totalSpace = _diskProvider.GetTotalSize(path);

                    if (!freeSpace.HasValue || !totalSpace.HasValue)
                    {
                        continue;
                    }

                    diskSpace = new DiskSpace
                    {
                        Path       = path,
                        FreeSpace  = freeSpace.Value,
                        TotalSpace = totalSpace.Value
                    };

                    diskSpace.Label = _diskProvider.GetVolumeLabel(path);
                }
                catch (Exception ex)
                {
                    if (!suppressWarnings)
                    {
                        _logger.Warn(ex, "Unable to get free space for: " + path);
                    }
                }

                if (diskSpace != null)
                {
                    yield return(diskSpace);
                }
            }
        }
예제 #4
0
        private IEnumerable<DiskSpace> GetDiskSpace(IEnumerable<String> paths, bool suppressWarnings = false)
        {
            foreach (var path in paths)
            {
                DiskSpace diskSpace = null;

                try
                {
                    var freeSpace = _diskProvider.GetAvailableSpace(path);
                    var totalSpace = _diskProvider.GetTotalSize(path);

                    if (!freeSpace.HasValue || !totalSpace.HasValue)
                    {
                        continue;
                    }

                    diskSpace = new DiskSpace
                                {
                                    Path = path,
                                    FreeSpace = freeSpace.Value,
                                    TotalSpace = totalSpace.Value
                                };

                    diskSpace.Label = _diskProvider.GetVolumeLabel(path);
                }
                catch (Exception ex)
                {
                    if (!suppressWarnings)
                    {
                        _logger.WarnException("Unable to get free space for: " + path, ex);
                    }
                }

                if (diskSpace != null)
                {
                    yield return diskSpace;
                }
            }
        }