WriteFile returning error 1784

前端 未结 2 986
逝去的感伤
逝去的感伤 2021-01-22 18:34

I am creating a program to populate a disk with a dummy file system.

Currently, I am writing files of variable sizes using WriteFile.

               


        
2条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-22 18:51

    My guess is that FileData is not large enough for you to write i * 1024 bytes from it. Is i the loop control variable for your list of files? If so, you need the write buffer FileData to grow 1K at a time as you loop through your files.

    This is an unusual construct. Are you sure the logic is correct here? Post more code (specifically, all usage of FileData and i) for better accuracy in the answers.

    Note that you should not always be checking GetLastError here - you need to check WriteFile's return code before you rely on that being meaningful. Otherwise you could be picking up an error from some unrelated part of your code - whatever failed last.

提交回复
热议问题