J
JigglyBit
Guest
Hello,
I am trying to get the following function call to work without luck. Would like it to create a file in a directory called a\ on the C drive. I don't even see the file created after executing.
int File() {
//HANDLE hFile;
BOOL errorFlag;
char dataBuffer[] = "Test file text.";
DWORD bytesToWrite = (DWORD)strlen(dataBuffer);
DWORD bytesWritten = 0;
HANDLE hFile = CreateFile(L"C:\\a\testing.txt", //file name
GENERIC_WRITE, //file operation type
FILE_SHARE_WRITE, //share?
NULL, //security permissions
OPEN_ALWAYS, //file access action type
FILE_ATTRIBUTE_NORMAL, //file attributes
NULL); //file attribute templates to be applied
if (hFile == INVALID_HANDLE_VALUE)
{
// DisplayError(TEXT("CreateFile"));
_tprintf(TEXT("Unable to open file \"%s\" for write.\n"), arg1);
return 1;
}
errorFlag = WriteFile(hFile, //handle to file
dataBuffer, //text to write
bytesToWrite, //number of bytes to write
&bytesWritten, //
NULL);
errorFlag = CloseHandle(hFile);
return 0;
}
Continue reading...
I am trying to get the following function call to work without luck. Would like it to create a file in a directory called a\ on the C drive. I don't even see the file created after executing.
int File() {
//HANDLE hFile;
BOOL errorFlag;
char dataBuffer[] = "Test file text.";
DWORD bytesToWrite = (DWORD)strlen(dataBuffer);
DWORD bytesWritten = 0;
HANDLE hFile = CreateFile(L"C:\\a\testing.txt", //file name
GENERIC_WRITE, //file operation type
FILE_SHARE_WRITE, //share?
NULL, //security permissions
OPEN_ALWAYS, //file access action type
FILE_ATTRIBUTE_NORMAL, //file attributes
NULL); //file attribute templates to be applied
if (hFile == INVALID_HANDLE_VALUE)
{
// DisplayError(TEXT("CreateFile"));
_tprintf(TEXT("Unable to open file \"%s\" for write.\n"), arg1);
return 1;
}
errorFlag = WriteFile(hFile, //handle to file
dataBuffer, //text to write
bytesToWrite, //number of bytes to write
&bytesWritten, //
NULL);
errorFlag = CloseHandle(hFile);
return 0;
}
Continue reading...