c# - Why was File.Delete designed not to throw when the file does not exist? -


from msdn file.delete

if file deleted not exist, no exception thrown.

it seems bad practice have low level api's hiding exceptional conditions , indeed seems rare case. motivation on one?

if try delete non-existent file, deleted, not exceptional. reason race condition created if tried confirm file's existence before deleting:

should call file.exists before calling file.delete?

this removes operation , avoids kind of race window.


Comments