Bug introduced in 10.3.0 or earlier and fixed in 11.1
Bug reproduced on Win but not on Mac
Reply from WRI Support:
[...] This indeed seems to be an issue with the Frontend on Windows and I have alerted the development team about this.
Unfortunately I do not have a work around at this moment other than manually deleting it (and I understand that is not something you are interested in). [...]
Problem:
So, if your notebook has a private stylesheet and this stylesheet has a parent stylesheet, you can't delete the parent, in the same FE session, even after the notebook is closed.
Something like Default.nb (private) and Core.nb (its parent).
Implications
If your application have a more complex StyleSheets system and you want to incorporate some kind of automatic updating of the app, you will have a bad time replacing Package/FrontEnd/Stylesheets part.
Minimal example:
We are going to create a notebook, its private stylesheet and the stylesheet that this parent inherits from.
dir = FileNameJoin[{$HomeDirectory, "Desktop", "directory"}];
CreateDirectory@dir;
SetDirectory@dir;
nb = Notebook[{
Cell[BoxData@RowBox@{"1", "+", "1"}, "Input"]},
StyleDefinitions -> FileNameJoin[{dir, "privateStyles.nb"}]
];
privateStyles = Notebook[{
Cell[StyleData[StyleDefinitions -> "defaultStyles.nb"]],
Cell[StyleData["Input"], FontSize -> 25]
}];
defaultStyles = Notebook[{
Cell[StyleData[StyleDefinitions -> "Default.nb"]],
Cell[StyleData["Input"], FontColor -> RGBColor[1, 0, 1]]
}
];
Export["defaultStyles.nb", defaultStyles];
Export["privateStyles.nb", privateStyles];
Export["testNb.nb", nb]; (*this will give an error but it doesn't matter*)
NotebookOpen[
FileNameJoin[{dir, "testNb.nb"}]
];
NotebookClose @ %;
DeleteFile /@ FileNames["*"]
DeleteFile::privv: Privilege violation for file or directory defaultStyles.nb. >>
{$Failed, Null, Null}
As you can see, the parent stylesheet can be easily deleted. Yet, its parent can't.
Question
Is there any way to proceed that doesn't involve closing the FrontEnd?
Edit by Mike H
This appears to be an OS or version specific problem: