IO::File::ReadBin and CopyBin returns FileNotFound error
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2020-02-11
11:00 AM
- last edited on
2022-11-30
10:44 AM
by
Daniel Kassai
2020-02-11
11:00 AM
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?
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?
~ReignBough~
ARCHICAD 27 INT (since AC18)
Windows 11 Pro, AMD Ryzen 7, 3.20GHz, 32.0GB RAM, 64-bit OS
ARCHICAD 27 INT (since AC18)
Windows 11 Pro, AMD Ryzen 7, 3.20GHz, 32.0GB RAM, 64-bit OS
Labels:
- Labels:
-
Add-On (C++)
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2020-02-11 12:21 PM
2020-02-11
12:21 PM
I've used this function in my code without problems. Could you post some code to show what you're doing?
Ralph Wessel BArch
Central Innovation
Central Innovation
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2020-02-12 03:05 AM
2020-02-12
03:05 AM
//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;
binPath.Set(apxPath);
IO::Name fname = IO::Name(/*input: filename without extension*/);
fname.Append(".bin"); // file extension
err = binPath.AppendToLocal(fname);
//binPath.PrintDebug();
// 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
++szStr;
// 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
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;
binPath.Set(apxPath);
IO::Name fname = IO::Name(/*input: filename without extension*/);
fname.Append(".bin"); // file extension
err = binPath.AppendToLocal(fname);
//binPath.PrintDebug();
// 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
++szStr;
// 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
~ReignBough~
ARCHICAD 27 INT (since AC18)
Windows 11 Pro, AMD Ryzen 7, 3.20GHz, 32.0GB RAM, 64-bit OS
ARCHICAD 27 INT (since AC18)
Windows 11 Pro, AMD Ryzen 7, 3.20GHz, 32.0GB RAM, 64-bit OS