Method to delete a file using c++

Thank you it works great but will crash if you have an invalid filename as your comment states.
so a small addition to prevent any crash would be :


//Make sure the path I have is valid both in characters and in that the file path actually exists
if(!MyFile.isEmpty())
{
    if (FPaths::ValidatePath(MyFile) && FPaths::FileExists(MyFile))
    {
        IFileManager& FileManager = IFileManager::Get(); FileManager.Delete(*MyFile);
    }
}

Once again thank you!

3 Likes