Microsoft KB Archive/251427

From BetaArchive Wiki

BUG: GetDiskFreeSpaceEx() Fails with Error 123 When it Is Passed a Subdirectory Containing Two (or More) Periods


The information in this article applies to:

  • Microsoft Win32 Application Programming Interface (API), included with:
    • Microsoft Windows 95
    • Microsoft Windows 98
    • Microsoft Windows 98 Second Edition


The GetDiskFreeSpaceEx function fails and the GetLastError function reports Error 123 when the GetDiskFreeSpaceEx function is called by using a directory name that contains more than a single period, such as "c:\v3.2.1" (assume that v3.2.1 exists).

If the GetDiskFreeSpaceEx function is called by using the short name (that is, "c:\v32~1"), the problem still occurs.


To work around this problem, avoid using more than one period in a directory name. For example, replace periods in directory names with dashes. Instead of naming a directory "v3.2.1", name the directory "v3_2_1".


Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.


Steps to Reproduce Behavior

  1. Type md c:\v3.2.1 at a command-line prompt.
  2. Run the sample code with the "c:\v3.2.1" parameter. Note that Error 123 is returned.
  3. Run the code by using the short directory name (for example, "c:\v32~1") and notice that Error 123 is returned in this case as well.

Sample Code

#include <windows.h>
#include <stdio.h>

int main(int argc, char* argv[])
    ULARGE_INTEGER  ulTotalSpace;
    ULARGE_INTEGER  ulUserSpace;
    ULARGE_INTEGER  ulFreeSpace;
    LPSTR lpDirectoryName = "c:";

    if(argc > 1)
        lpDirectoryName = argv[1];

    if(GetDiskFreeSpaceEx(lpDirectoryName, &ulUserSpace, &ulTotalSpace, &ulFreeSpace) == TRUE){
        printf("User Space  = %I64u\n", ulUserSpace.QuadPart);
        printf("Total Space = %I64u\n", ulTotalSpace.QuadPart);
        printf("Free Space  = %I64u\n", ulFreeSpace.QuadPart);
        printf("error occurred %u\n", GetLastError());

    return 0;

Additional query words:

Keywords : kbAPI kbFileIO kbKernBase kbOSWin95 kbOSWin98 kbDSupport kbGrpDSKernBase
Issue type : kbbug
Technology : kbAudDeveloper kbWin32sSearch kbWin32API

Last Reviewed: December 16, 2000
© 2001 Microsoft Corporation. All rights reserved. Terms of Use.