This project is read-only.

Possible wrong implementation of Volume.GetDiskFreeSpace()

Oct 4, 2011 at 11:53 PM
thanks for reporting them, I'll check tonight and if there is a bug
will create a test case as well.

Sincerely,
Alexandr Normuradov



On 4 October 2011 05:10, jjangli <notifications@codeplex.com> wrote:
> From: jjangli
>
> I am trying to retrieve the cluster size of a Volume.
> Before AlphaFS I used the Win32 GetdiskFreeSpace() method for this.
>
> After some digging it seems that the AlphaFS signature for the
> GetDiskFreeSpace() method is not correct, it is being used as the
> GetDiskFreeSpaceEx() method.
>
> Volume.cs:
>
> public static DiskSpaceInfo GetDiskFreeSpace(string directory)
> {
> UInt64 freeBytesAvailable, totalNumberOfBytes, totalNumberOfFreeBytes;
> if (!NativeMethods.GetDiskFreeSpaceEx(directory, out freeBytesAvailable,
> out totalNumberOfBytes, out totalNumberOfFreeBytes))
> throw new Win32Exception();
> return new DiskSpaceInfo(freeBytesAvailable, totalNumberOfBytes,
> totalNumberOfFreeBytes);
> }
>
> The definition "error" is in the use of GetDiskFreeSpaceEx() method, which
> is not the same as the GetdiskFreeSpace() method.
>
> According to Microsoft:
>
> BOOL WINAPI GetDiskFreeSpace(
> __in   LPCTSTR lpRootPathName,
> __out  LPDWORD lpSectorsPerCluster,
> __out  LPDWORD lpBytesPerSector,
> __out  LPDWORD lpNumberOfFreeClusters,
> __out  LPDWORD lpTotalNumberOfClusters
> );
>
> http://msdn.microsoft.com/en-us/library/windows/desktop/aa364935%28v=vs.85%29.aspx
>
> BOOL WINAPI GetDiskFreeSpaceEx(
> __in_opt   LPCTSTR lpDirectoryName,
> __out_opt  PULARGE_INTEGER lpFreeBytesAvailable,
> __out_opt  PULARGE_INTEGER lpTotalNumberOfBytes,
> __out_opt  PULARGE_INTEGER lpTotalNumberOfFreeBytes
> );
>
> http://msdn.microsoft.com/en-us/library/windows/desktop/aa364937%28v=vs.85%29.aspx
>
> Read the full discussion online.
>
> To add a post to this discussion, reply to this email
> ([email removed])
>
> To start a new discussion for this project, email
> [email removed]
>
> You are receiving this email because you subscribed to this discussion on
> CodePlex. You can unsubscribe or change your settings on codePlex.com.
>
> Please note: Images and attachments will be removed from emails. Any posts
> to this discussion will also be available online at codeplex.com