Microsoft KB Archive/251427: Difference between revisions

From BetaArchive Wiki
m (1 revision imported: importing part 2)
m (Text replacement - """ to """)
 
(3 intermediate revisions by the same user not shown)
Line 25: Line 25:
== SYMPTOMS ==
== SYMPTOMS ==


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 &quot;c:\v3.2.1&quot; (assume that v3.2.1 exists).<br />
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).<br />
<br />
<br />
If the '''GetDiskFreeSpaceEx''' function is called by using the short name (that is, &quot;c:\v32~1&quot;), the problem still occurs.
If the '''GetDiskFreeSpaceEx''' function is called by using the short name (that is, "c:\v32~1"), the problem still occurs.


<br />
<br />
Line 34: Line 34:
== RESOLUTION ==
== RESOLUTION ==


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 &quot;v3.2.1&quot;, name the directory &quot;v3_2_1&quot;.
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".


<br />
<br />
Line 51: Line 51:


# Type '''md c:\v3.2.1''' at a command-line prompt.
# Type '''md c:\v3.2.1''' at a command-line prompt.
# Run the sample code with the &quot;c:\v3.2.1&quot; parameter. Note that Error 123 is returned.
# Run the sample code with the "c:\v3.2.1" parameter. Note that Error 123 is returned.
# Run the code by using the short directory name (for example, &quot;c:\v32~1&quot;) and notice that Error 123 is returned in this case as well.
# 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 ====
==== Sample Code ====


<pre class="CODESAMP">#include &lt;windows.h&gt;
<pre class="CODESAMP">#include <windows.h>
#include &lt;stdio.h&gt;
#include <stdio.h>


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


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


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



Latest revision as of 13:52, 21 July 2020

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

Q251427



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





SYMPTOMS

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.



RESOLUTION

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".



STATUS

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



MORE INFORMATION

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);
    }
    else
    {
        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.