End Google Ads 201810 - BS.net 01 --> Hello,
my program takes in a large file(s) of byte code and writes it into thousands of smaller files.
The program gives an MFC42D.DLL: 0xC00000005 Access Violation when it reaches the first of two lines of code below.

siteAndChannelIDStr.Format("C:\\Network Data\\Unclassified Events\\Last Extracted\\%s\\#%d\\", siteNamesArray[listBoxIndex], OCUIDfromEALFile);
CreateDirectory(siteAndChannelIDStr, NULL);


The CString object and directory are successfully created during the previous iterations, but oddly fails this time round.

I have followed the program execution using the debugger and it falls down at "if" statement in the "Advanced direct buffer access" bit in MFC\SRC\STRCORE.cpp


if (GetData()->nRefs > 1 || nMinBufLength > GetData()->nAllocLength)


I have tried setting siteAndChannelIDStr = ""; after use
And changing the Format function to one described on the microsoft website <a href="http://support.microsoft.com/kb/127038">
And tried using CString Arrays for the siteNamesArray

But no luck!
Has anyone come across this type of problem before?

I have tried the program out on 3 different files, but it fails at the same line (although prog had passed this line for each previous hundreds of iterations)

It fails after subfile 4977/10893 in file1
after subfile 4901/8135 in file2
after subfile 384/13321 in file3

Any help would be greatly appreciated!
I can provide more information if necessary. I cannot put up source code as it is for my work.

Thanks,
Colm