10-28-2021 03:05 AM
Hello, I am trying to save data that is constantly generated as a .bin file, in a multithreaded system, the code that specifically saves the file, is
static int CVICALLBACK Save11Function(void *functiondata)
{
thread11=0;
for(int i=0; i<MAX_ITEMS_IN_QUEUE_READ_BLOCK; i++)
{
sprintf (Phase11tempbin, "Image11 %d.bin", global11);
global11++;
MakePathname ("c:\\Users\\Public\\Documents\\test", Phase11tempbin, Phase11bin);
ArrayToFile (Phase11bin, savebuffer11[i].pixels, VAL_UNSIGNED_CHAR, lBuffSize, 1, VAL_DATA_MULTIPLEXED, VAL_GROUPS_AS_ROWS, VAL_SEP_BY_COMMA, 1, VAL_BINARY, VAL_TRUNCATE);
}
printf("thread11");
thread11=1;
return 1;
}
but I am constantly getting this error:
NON-FATAL RUN-TIME ERROR: "tsqsave.c", line 975, col 9, thread id 14628, function id 19: Function ArrayToFile: (return value == -1 [0xffffffffffffffff]). File exists
What am I doing wrong? I am not even able to understand what does this error mean? Any suggestions would be helpful! Thank You!
Solved! Go to Solution.
11-09-2021 05:35 AM - edited 11-09-2021 05:37 AM
Well the error clearly states that the file already exists, most likely from a previous run of your program.
You either must add some extra unique information to the filename such as the current time and date, or first check that the file doesn't exist and if it does delete it, since ArrayToFile() doesn't want to overwrite an already existing file.
11-09-2021 06:16 AM
Yes, it was that exact issue. Thank you for the suggestion!