Hint: You can edit your post, highlight your code and press the <> formatting button. This will not automatically indent your code. That part is up to you.
You can use the preview button at the bottom to see how it looks.
I found the second link to be the most help.
Without code it is just guess at what you are trying to do. And sometimes not easy to understand what you need.
the simplest way to delete a file is to borrow the operating system.
the easiest way to do this for a beginner is system:
system("rm filename");
which is the same as typing that string in a unix console. you can put a path on it etc just like in the console.
there are other ways that are safer (system is a security risk in professional software) but as you seem to be very new, we can save that for later.
Honestly not sure what you mean by virtual file ... are you using a virtual file system, or simulating a file in memory, or something else? The above assumes a virtual file system that works like a unix file system.... ?