Microsoft KB Archive/51326

= DOC: tmpfile Creates a Temporary File in the Root Dir =

Article ID: 51326

Article Last Modified on 7/5/2005

-

APPLIES TO

 The C Run-Time (CRT), when used with:  Microsoft Visual C++ 1.0 Professional Edition

 Microsoft Visual C++ 1.5 Professional Edition

 Microsoft Visual C++ 1.0 Professional Edition

 Microsoft Visual C++ 2.0 Professional Edition</li></ul>

 Microsoft Visual C++ 2.1</li></ul>

 Microsoft Visual C++ 4.0 Standard Edition</li></ul>

 Microsoft Visual C++ 5.0 Standard Edition</li></ul>

 Microsoft Visual C++ 6.0 Service Pack 5</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q51326

<div class="notice_section">

<div class="summary_section">

SUMMARY
The Microsoft C run-time library function tmpfile creates a temporary file in the root directory of the current drive. This file has read/write access and is automatically deleted when the file is closed.

The documentation for this function implies that the file will be created in the current working directory. This is not the case; the file will exist only in the root directory. To create a temporary file in a different directory, use the functions tmpnam or tempnam in conjunction with fopen.

Some obscure side effects can occur on some systems as a result of tmpfile creating a file in the root directory. On a network, you must have read/write privileges for the root directory of your current drive. Without these rights, tmpfile will fail to open the temporary file, returning a NULL in the process.

Another possible reason tmpfile might fail is if the root directory is full. MS-DOS allows only a limited amount of file entries in the root directory depending on the disk format; therefore, if the root is full, you must delete some files before you use tmpfile.

Additional query words: Novell

Keywords: kbcrt kbaccess200fix kbdocfix kbdocerr KB51326

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.