Error 5019 (File not found) in ResourceCreate()

 

Hi,

i'm trying to read a bitmap file using the ResourceCreate() function. The file exists in the MQL5\\Files folder so that calling FileIsExist(ImageFileName) returns TRUE.

In contrast, the “ResourceCreate” function returns error 5019 which means that the file does not exist. 

I have tried everything possible: Working with absolute paths, putting the file in other folders, etc.

The file cannot seem to be found.

What am I doing wrong? 

Here's my code, any help is really appreciated.

string ImageFileName = "test.bmp";

if (!ResourceCreate("test", ImageFileName))
{
    Print("Last error: " + GetLastError() + " (" + ImageFileName + ")");
    return false;
}


Regards,
Chris

 
crs247:

Hi,

i'm trying to read a bitmap file using the ResourceCreate() function. The file exists in the MQL5\\Files folder so that calling FileIsExist(ImageFileName) returns TRUE.

In contrast, the “ResourceCreate” function returns error 5019 which means that the file does not exist. 

I have tried everything possible: Working with absolute paths, putting the file in other folders, etc.

The file cannot seem to be found.

What am I doing wrong? 

Here's my code, any help is really appreciated.


Regards,
Chris

If there is no backslash, then the resource is searched starting from the folder where the executable file from which we call the function is located.

https://www.mql5.com/en/book/advanced/resources/resources_resourcecreate#:~:text=ResourceCreate(%22%3A%3AMyImage%22,added%20to%20the%20name%20automatically).

If you are doing everything correct check the formatting of the file is correct. You need to convert the file into an actual .bmp format. Simply renaming and change the formatting might not work.
MQL5 Book: Advanced language tools / Resources / Dynamic resource creation: ResourceCreate
MQL5 Book: Advanced language tools / Resources / Dynamic resource creation: ResourceCreate
  • www.mql5.com
The #resource directives embed resources into the program at the compilation stage, and therefore they can be called static. However, it often...
 
crs247:

Hi,


As Muhammad said, using your code, the ea is looking for the resource in the same folder as your code file.

 
Muhammad Azal #:
If there is no backslash, then the resource is searched starting from the folder where the executable file from which we call the function is located.

https://www.mql5.com/en/book/advanced/resources/resources_resourcecreate#:~:text=ResourceCreate(%22%3A%3AMyImage%22,added%20to%20the%20name%20automatically).

If you are doing everything correct check the formatting of the file is correct. You need to convert the file into an actual .bmp format. Simply renaming and change the formatting might not work.


That was exactly the reason.

As soon as I reference the file in this way, everything works as intended:

ResourceCreate("test", "\\Files\\" + ImageFileName)


Thank you very much!