I open the picture from the program in the standard "View Windows Photos" in this way:

System.Diagnostics.Process proc = new System.Diagnostics.Process(); proc.StartInfo.FileName = "1.jpg"; proc.Start(); 

How to programmatically prohibit the deletion of images after its opening?

  • 2
    Uh, nothing? User in his car, the king and god. - VladD
  • I need to prevent precisely accidental deletion. For example, if the picture is open, the user can delete it by accidentally pressing delete. With this and need to cope - dantt3

1 answer 1

You can follow proc.Start(); execute File.Open . Then the file will not be deleted, because the program will keep it.

However, if the user is an admin on the PC, then he can safely unblock and delete it with something.

  • Unfortunately, this method did not work. The file can no longer be changed, but it is also deleted. - dantt3
  • @ dantt3: Have you tried FileShare.Read ? - VladD
  • @VladD: Yes. Alas, there is no effect - dantt3
  • @ dantt3: Strange. Don't you close the file ahead of time? Maybe your application terminates immediately after launching the viewer? - VladD
  • @VladD: And really, I'm blind, I forgot to take the stream. Thank you so much - dantt3