Click here to Skip to main content
13,091,300 members (53,033 online)
Rate this:
Please Sign up or sign in to vote.
Hello to everybody
I have C# project and when somebody delete project's exe(project.exe) I dont wanted to be deleted.
Can I do project.exe's visible false when when somebody trying to delete ?
Or can I give MessageBox("you cannot delete exe") when somebody trying to delete ?
It looks like triggers (instead of delete triggers etc.).
Posted 3-Aug-12 3:31am
Updated 5-Aug-12 21:38pm
Collin Jasnoch 3-Aug-12 9:40am
This makes no sense. You are deleting the file but do not want it deleted?
Solution is to not delete the file.
Member 8192632 6-Aug-12 4:03am
you are right ;not to delete the file can be solution.
But my question different :is there a way to make my question
aspnet_regiis 3-Aug-12 9:42am
Even if it is deleted, then you can recover it from recycle bin.. So not to worry
Member 8192632 6-Aug-12 4:00am
if I shift-delete ? what will happen ?
aspnet_regiis 6-Aug-12 4:48am
Better way you should use Windows + R > cmd 'Enter' > FORMAT D: .... Its better then Shift+Delete
Member 8192632 8-Aug-12 3:09am
yes better :)
is there a way to make its visible false ?
Wes Aday 3-Aug-12 9:42am
Sure you can do that but there is no point. The only reason that someone would "hide" the exe would be if they are writing malicious software.
Member 8192632 3-Aug-12 9:46am
ıt looks like trigger (instead of delete triggers etc.)
But I want to learn how to do in C# too.
I solved it's logic but I can't do with codes in C#
Wes Aday 3-Aug-12 9:49am
That makes no sense at all.
Member 8192632 3-Aug-12 9:53am
yes it will make sense a little :)
sure not so important but I want to learn
Wes Aday 3-Aug-12 9:58am
Learn what? Nothing you have said makes any sense at all. I realize the English may not be your native language but your question and comments do not make any sense.
Dave Kreskowiak 3-Aug-12 10:43am
Actually, no it doesn't make any sense.

If you're asking how to prevent the .EXE file from being deleted, you don't do anythis at all. Default security configuration prevents normal users from doing ANYTHING at all, including deleting files, to anything under Program Files or it's subfolders.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

The only way to accomplish this is to have a second program that monitors "project.exe". In Windows, you can't delete an executable that's running, and if it isn't running it can't do anything. There are no events sent to a program upon it's deletion because it isn't running, so there is no place to send events to.

But even if you wrote a second program, it's a trivial task to stop that one from running and delete it anyways. What you're asking for is simply too impractical for any normal use (the only place I've seen similar behavior is malware, so you'll have to excuse me if I won't go into any more details).
Member 8192632 3-Aug-12 18:37pm
i really want to learn C#`s deepness .ok no problem if you dont want to get into details any more
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

You own the software ..not the user's computer..So let the user decide whether to keep your program or delete it..You should not force him to keep your software. The user can file a law suit against you if he is unable to delete your program.

Read more details here related a similar case ..[^]
Member 8192632 8-Aug-12 3:10am
Not for other users İt just for me
I dont want anybody to delete my project...
and if delete just make visible false and let him happy :)))

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.170813.1 | Last Updated 6 Aug 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100