, 다음은 (적어도 크기, 가장 일반적으로 필요한 것입니다 얻을) C#에서 좋은 작품 이 양식에 여러 파일에 분산 작업 코드에서 비트와 조각)이지만 :
/// <summary>
/// A compilation of the properties of folders and files in a file system.
/// </summary>
public struct FileSystemProperties
{
private FileSystemProperties(long? totalBytes, long? freeBytes, long? availableBytes)
: this()
{
TotalBytes = totalBytes;
FreeBytes = freeBytes;
AvailableBytes = availableBytes;
}
/// <summary>
/// Gets the total number of bytes on the drive.
/// </summary>
public long? TotalBytes { get; private set; }
/// <summary>
/// Gets the number of bytes free on the drive.
/// </summary>
public long? FreeBytes { get; private set; }
/// <summary>
/// Gets the number of bytes available on the drive (counts disk quotas).
/// </summary>
public long? AvailableBytes { get; private set; }
/// <summary>
/// Gets the properties for this file system.
/// </summary>
/// <param name="volumeIdentifier">The path whose volume properties are to be queried.</param>
/// <param name="cancel">An optional <see cref="CancellationToken"/> that can be used to cancel the operation.</param>
/// <returns>A <see cref="FileSystemProperties"/> containing the properties for the specified file system.</returns>
public static FileSystemProperties GetProperties(string volumeIdentifier)
{
ulong available;
ulong total;
ulong free;
if (GetDiskFreeSpaceEx(volumeIdentifier, out available, out total, out free))
{
return new FileSystemProperties((long)total, (long)free, (long)available);
}
return new FileSystemProperties(null, null, null);
}
/// <summary>
/// Asynchronously gets the properties for this file system.
/// </summary>
/// <param name="volumeIdentifier">The path whose volume properties are to be queried.</param>
/// <param name="cancel">An optional <see cref="CancellationToken"/> that can be used to cancel the operation.</param>
/// <returns>A <see cref="Task"/> containing the <see cref="FileSystemProperties"/> for this entry.</returns>
public static async Task<FileSystemProperties> GetPropertiesAsync(string volumeIdentifier, CancellationToken cancel = default(CancellationToken))
{
return await Task.Run(() =>
{
ulong available;
ulong total;
ulong free;
if (GetDiskFreeSpaceEx(volumeIdentifier, out available, out total, out free))
{
return new FileSystemProperties((long)total, (long)free, (long)available);
}
return new FileSystemProperties(null, null, null);
}, cancel);
}
}
리눅스 또는 Mac에서이를 사용하지 마십시오 - 그것은 사람들을 위해 다시 작성되어야 할 것이다 (그리고 나 ' 관심을 보일 것).