I'm trying to delete a font file using this way,
std::filesystem::remove(std::filesystem::path("C:\\Windows\\Fonts\\segmdl2.ttf"));
But this fails and throw an exception,
filesystem:error cannot remove: Input/output error
The exception is not helpful. What's the correct way to delete this kind of files?
Update,
I made an attempt to delete it from Powershell and it throw following error,
del C:\Windows\Fonts\segmdl2.ttf
del : Cannot remove item C:\Windows\Fonts\segmdl2.ttf: Access to the path 'C:\Windows\Fonts\segmdl2.ttf' is denied.
At line:1 char:1
+ del C:\Windows\Fonts\segmdl2.ttf
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : PermissionDenied: (C:\Windows\Fonts\segmdl2.ttf:FileInfo) [Remove-Item], UnauthorizedAcc
essException
+ FullyQualifiedErrorId : RemoveFileSystemItemUnAuthorizedAccess,Microsoft.PowerShell.Commands.RemoveItemCommand
I even tried to remove it directly from font folder, I'm getting an error that it can't be done because an another application already using the font.
But I was successfully able to delete it from the command prompt.
How does cmd do this?
I need to achieve same level for my app.