Using the C Run-time function stat to check a directory fails when the name passed to the function ends with a backslash (\) (168439)
The information in this article applies to:
- The C Run-Time (CRT), when used with:
- Microsoft Visual C++, 32-bit Enterprise Edition 5.0
- Microsoft Visual C++, 32-bit Enterprise Edition 6.0
- Microsoft Visual C++, 32-bit Professional Edition 5.0
- Microsoft Visual C++, 32-bit Professional Edition 6.0
- Microsoft Visual C++, 32-bit Learning Edition 6.0
- Microsoft Visual C++ .NET (2002)
- Microsoft Visual C++ .NET (2003)
This article was previously published under Q168439 SYMPTOMS Using the C Run-time function stat to check a directory
fails when the name passed to the function ends with "\".
For
example, _stat("\\my_directory\\my_name",&buf) returns OK, but
_stat("\\my_directory\\my_name\\",&buf) will return -1 as error.
CAUSE The _stat function calls the windows API function
FindFirstFile passing it the path name. The FindFirstFile returns an invalid
handle if the name ends with "\." RESOLUTION Remove the trailing "\" from the path name. STATUS
This behavior is by design.
Modification Type: | Major | Last Reviewed: | 9/7/2005 |
---|
Keywords: | kbtshoot kbprb KB168439 kbAudDeveloper |
---|
|