Los eventos FileSystemWatcher Delete y Shift + Delete son diferentes

FileSystemWatcher C#

Folder Structure C:\A\B\C\D\E\F\abc.txt

Delete a nested folder B fires only one event for the root folder B

But Shift + Delete fires the events for all sub folders and files.

I need to get Delete nested folder events same as Shift + Delete

The below question is similar to my requirement, but it's not working

C # FileSystemWatcher.Deleted no dispara en la eliminación "normal"?

preguntado el 09 de marzo de 12 a las 17:03

Why does monitoring renames not work? What happens? -

No its not working if I delete -

@HPFE455 - You've already been told there is not a single event that works for both cases. Why ask the question again? -

Babcock, my previous question was not clear, I cant delete that question, I was asking about the recyle bin also, I thougt that question was a confusing one. I found similar question above that mentioned. I need a solution very badly. I am sorry.. -

1 Respuestas

The below question is similar to my requirement, but it's not working

Define "not working". As mentioned in the accepted answer for question that you referenced, the default behavior in Windows is that when you press the delete key, the file is not actually deleted- it is emocionado to a special folder called the recycle bin.

Si manejas el rebautizado y cambiado events, you should see evidence of the moves to the recycle bin, but as you found the events will probably be raised only for the parent folder (see also Detectando archivos movidos usando FileSystemWatcher). There is probably no way to get the events for the child folders/files. If you need to keep track of the children, you'll need to index them into some data structure before they get deleted.

Also, keep in mind that some people (like me) disable the recycle bin altogether, and for us a delete is a delete.

contestado el 23 de mayo de 17 a las 13:05

I think this is the way I can resolve the issue. Maintain a list of files in the watch directory, while deleting, use the list values and deleted folder path and manipulate based on my requirement. - Ullan

That sounds right to me. Beware the other thing I mention, where the recycle bin is disabled altogether. - chris shain

@HPFE455 - Do you mean something like what was suggested to you 15 hours ago? - M.Babcock

@M.Babcock sorry I didn't see your answer over there- didn't mean to snipe the question. Gave you a +1 FWIW. - chris shain

Babcock, I accpted your comment as a solution. I am trying to implement that. thanks for understanding the functionality. - Ullan

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.