LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Regarding error while Saving File

Solved!
Go to solution

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!

0 Kudos
Message 1 of 3
(1,640 Views)
Solution
Accepted by cheney_ni_masi

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.

Rolf Kalbermatter
My Blog
0 Kudos
Message 2 of 3
(1,550 Views)

Yes, it was that exact issue. Thank you for the suggestion!

0 Kudos
Message 3 of 3
(1,540 Views)