ThisBugIt can be briefly described as follows: in useOpenfiledialogWhen you try to open a nonexistent file,OpenfiledialogIt will create a non-existent file and delete it, and then tell the user that the file does not exist.
Next we will write a program to reproduce thisBug. The basic principle is to useFilesystemwatcherTo monitor folders.
Created and used1As shown inProgram.
Figure1.Sample program
Select a folder and monitor file changes.
Figure2.Monitoring folder
Then, try to open a non-existent file in the monitored file. This file opening dialog box has been setCheckfileexistsAndCheckpathexistsIsTrue.
The method is simple.File NameEnter a non-existent file name, and click open.3.
Figure3.Open a nonexistent file
Then, in the file dialog box, a message box appears, indicating that the file does not exist.4.
Figure4.Message box does not exist in the file
Click Cancel. However, we will find thatOutput Message.5.
Figure5.Unreasonable File Creation and Deletion
Because the open file dialog box is actuallyAPICall. No ImageRecycltorLet's look at its implementation in the same simple way.
In additionSource codeAnd addedFileiopermissionTo prohibit writing to the monitoring file. But it has no effect at all. In fact, this is another security vulnerability. Because. NET FrameworkBefore callingAPIRelatedPermissionCheck. However, this check is not actually performed. (MaybeMSHave other considerations)
PS:WinformIn the open file dialog box also has such a problem, so it cannot be completely considered a WPF bug, but after all there is this problem in the WPF assembly, it is put in. (Not readCode, It should beAPI)
Others in the same seriesArticle:
[WPF bugLIST] (Collation)And(1 )--Multiple choice optionsListBox
[WPF bugLIST]Of(2) -- radiobuttonOfIscheckedBinding invalid
[WPF bugLIST]Of(4 )--ClickRadiobuttonNo response to blank
[WPF bugLIST]Of(5 )--Hide the modal dialog box and convert it to non-modal Mode
[WPF bugLIST]Of(6) -- buttonOfIscancelAttribute invalid
[WPF bugLIST]Of(7 )--StubbornError Template
[WPF bugLIST]Of(8) -- rowdefinitionMediumMaxheightInvalid under certain conditions
[WPF bugLIST]Of(9 )--Disappearing cursor