rachelason
Programmer
hello,
I want to create a file in users temp folder. Is there any c++ code to locate temp folder?
thanks
I want to create a file in users temp folder. Is there any c++ code to locate temp folder?
thanks
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
// Get the temp path.
dwRetVal = GetTempPath(dwBufSize, // length of the buffer
lpPathBuffer); // buffer for path
if (dwRetVal > dwBufSize)
{
printf ("GetTempPath failed with error %d.\n",
GetLastError());
return (2);
}
// Create a temporary file.
uRetVal = GetTempFileName(lpPathBuffer, // directory for tmp files
"NEW", // temp file name prefix
0, // create unique name
szTempName); // buffer for name
if (uRetVal == 0)
{
printf ("GetTempFileName failed with error %d.\n",
GetLastError());
return (3);
}
// Create the new file to write the upper-case version to.
hTempFile = CreateFile((LPTSTR) szTempName, // file name
GENERIC_READ | GENERIC_WRITE, // open r-w
0, // do not share
NULL, // default security
CREATE_ALWAYS, // overwrite existing
FILE_ATTRIBUTE_NORMAL,// normal file
NULL); // no template
if (hTempFile == INVALID_HANDLE_VALUE)
{
printf ("CreateFile failed with error %d.\n",
GetLastError());
return (4);
}