You should check if the file was opened correctly. I think either of these work.
if (imfile)
{
// File is open
}
else
{
// Error
}
Or
if (imfile.is_open())
{
// File is open
}
else
{
// Error
}
edit:
If you want to get the file path of an asset, you can use the following code. Note that you’ll have to specifically add your file to your package if you intend to ship it. It’s in Project Settings->Project->Packaging. Then expand the Advanced section and add the folder to “Additional Non-Asset Directories to Package”.
const FString AbsoluteGameContentDir = FPaths::ConvertRelativePathToFull(FPaths::ProjectContentDir());
FString FileAbsolutePath = FPaths::ConvertRelativePathToFull(FPaths::Combine(AbsoluteGameContentDir, FilePathRelativeToContent));