WriteFile seems to... not write to the file

Heyo, I've been using WriteFile to write to a file. And previously it worked fine, although I'm not sure what changed that would allow it to not write anymore... Some more info:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
void
saveFile(FileInfo *file, char *filename)
{
    HANDLE fileHandle = CreateFileA(filename, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, 0, 0);
    if(fileHandle != INVALID_HANDLE_VALUE)
    {
        DWORD bytesWritten;
        int error = WriteFile(fileHandle, (void *)file->contents, (DWORD)file->filesize, &bytesWritten, 0);

        CloseHandle(fileHandle);
    }
}


So WriteFile doesn't return any errors, and it have a fileHandle, and GetLastError returns that the file already exists. bytesWritten is always exactly how many bytes I want to be written (the filesize).

The only thing I can think of that might have changed inbetween those times is that I add a null at the end of the file, but I don't include it when saving the file. Would a null be preventing the WriteFile from completing it's task?
Gosh dangit... This always happens to me... I got it, I'm retarded.

How do I delete this forum post?
Now you have to tell us what you were doing wrong :)
Exactly don't be a DenverCoder9

Edited by ratchetfreak on
I have this cartoon on my door at work.
I literally had it writing to a hardcoded filename, so even if I loaded foo.wat it was going to save to hardcoded bar.omg.

Not exactly a satisfying answer. :c

Edited by Jesse Coyle on Reason: realized it's a spoiler