943,651 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Marked Solved
  • Views: 813
  • C# RSS
Sep 17th, 2009
0

File Search for Application Protection

Expand Post »
Hi everyone. Basically what I want to do is search for a specific *.exe file upon initialization of my application. The *.exe file that I want to search for happens to be a .NET debugging tool. When / if my application finds this file, I want it to automatically close and delete itself. The problem is, not everybody will have that *.exe file installed in the same place. Is there a way I can search the entire HD instead of specific folders to find the file? Would @"C:\" search the desktop, My Documents, etc? I'm also not really sure how I can make my program delete itself upon detection; maybe I should start a new thread for that after I figure this out.

Thanks in advance
Similar Threads
Reputation Points: 55
Solved Threads: 18
Junior Poster
papanyquiL is offline Offline
168 posts
since May 2009
Sep 18th, 2009
0

Re: File Search for Application Protection

Why would you want your application to delete itself?
Reputation Points: 341
Solved Threads: 233
Posting Shark
DdoubleD is offline Offline
984 posts
since Jul 2009
Sep 18th, 2009
0

Re: File Search for Application Protection

This piece of code enumerate on the local drives then gets it root path then search for every exe on you can use SystemFileInfo to handle nested directories...
C# Syntax (Toggle Plain Text)
  1. foreach (System.IO.DriveInfo dirveInfo in System.IO.DriveInfo.GetDrives())
  2. {
  3. foreach(System.IO.FileInfo fileInfo in dirveInfo.RootDirectory.GetFiles("*.exe"))
  4. ///add the exe in list or handle it as you like
  5. }
Last edited by Ramy Mahrous; Sep 18th, 2009 at 11:21 am.
Featured Poster
Reputation Points: 480
Solved Threads: 276
Postaholic
Ramy Mahrous is offline Offline
2,189 posts
since Aug 2006
Sep 18th, 2009
0

Re: File Search for Application Protection

What are you trying to accomplish here? I only can only think of one type of software that behaves like this.............

Please elaborate
Featured Poster
Reputation Points: 1749
Solved Threads: 735
Senior Poster
sknake is offline Offline
3,948 posts
since Feb 2009
Sep 18th, 2009
0

Re: File Search for Application Protection

Basically I'm adding a few levels of protection scheme. I'm searching all drives for programs like .NET Reflector and some various .NET deobfuscation / debugging tools. When/if these are found my program will delete itself. I have all of this ontop of a custom serial algorithm based on Genetics and Sudoku(LOL). Of course, if this were commercial software I would never go through that much trouble, but it's for a class I'm in to help demonstrate security vulnerabilities.
Reputation Points: 55
Solved Threads: 18
Junior Poster
papanyquiL is offline Offline
168 posts
since May 2009
Sep 18th, 2009
0

Re: File Search for Application Protection

I still don't understand, but to search an entire drive for a file is not difficult to do:
C# Syntax (Toggle Plain Text)
  1. DirectoryInfo di = new DirectoryInfo(@"c:\");
  2. FileInfo[] finfos = di.GetFiles("*.exe", SearchOption.AllDirectories);
  3. foreach (FileInfo fi in finfos)
  4. ; // do something with the file info
Reputation Points: 341
Solved Threads: 233
Posting Shark
DdoubleD is offline Offline
984 posts
since Jul 2009
Sep 18th, 2009
0

Re: File Search for Application Protection

Something I begun to note is most of askers ignore my reply... and even don't comment, what does it mean????!!!
@papanyquiL didn't you see my reply?? or I should clarify?? or you aren't satisfied with the code??
Last edited by Ramy Mahrous; Sep 18th, 2009 at 4:08 pm.
Featured Poster
Reputation Points: 480
Solved Threads: 276
Postaholic
Ramy Mahrous is offline Offline
2,189 posts
since Aug 2006
Sep 19th, 2009
0

Re: File Search for Application Protection

Something I begun to note is most of askers ignore my reply... and even don't comment, what does it mean????!!!
@papanyquiL didn't you see my reply?? or I should clarify?? or you aren't satisfied with the code??
Yes Ramy I saw your reply and it worked fine. I just forgot to mark this thread as solved because I was answering some other questions. Thanks for the help everyone
Reputation Points: 55
Solved Threads: 18
Junior Poster
papanyquiL is offline Offline
168 posts
since May 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: How do I access this?
Next Thread in C# Forum Timeline: Monodevelop and Linux libraries





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC