The Global Archicad Community

Stay informed. Get help. Share your knowledge.

Discussions about using GRAPHISOFT's tools (Archicad API, BIMx API, BIMcloud API) for independent software developers

Moderators: Karl Ottenstein, LaszloNagy, ejrolon, Barry Kelly, gkmethy, rmasaki, MOREH Tamas, Akos Somorjai, Ed Brown, Mihály Palenik, Tibor Lorántfy

I created a function that supposed to read a binary file.

I was able to open (IO::File::Open) the file without error but when I read (IO::File::ReadBin) the file, it returns 0x81000100 (FileNotFound) and the "destination" is empty. When I copy (IO::File::CopyBin) it, it also returns the same error but the content was copied. EDIT: Copied to "destination".

Why it return this error?
Last edited by ReignBough on Wed Feb 12, 2020 2:50 am, edited 1 time in total.
//err = IO::fileSystem.GetSpecialLocation(IO::FileSystem::ApplicationFolder, &apxPath); // not APX location
LPSTR apxPath = new TCHAR[_MAX_PATH];
GetModuleFileName((HINSTANCE)&__ImageBase, apxPath, _MAX_PATH);
char* pos = str_lastchr(apxPath, '\\');
pos[1] = 0; // get only the location

IO::Location binPath;
IO::Name fname = IO::Name(/*input: filename without extension*/);
fname.Append(".bin"); // file extension
err = binPath.AppendToLocal(fname);

// open file
IO::File srcFile(binPath);
err = srcFile.Open(IO::File::ReadMode); <== no error here

// get size
USize szStr = 0;
err = srcFile.GetDataLength(&szStr); <== no error here, returns correct file size

// read file
char* srcStr = new char[szStr]();
//err = srcFile.ReadBin(srcStr, szStr); <== returns 0x81000100 (FileNotFound), srcStr is empty
err = srcFile.CopyBin(srcStr, szStr); <== returns 0x81000100 (FileNotFound), srcStr contains what I needed