1

Here's my full concept: I want to be able to search the entire ‪C:\ & D:\ to see if a certain file exists on the drive - not edit/delete/create, I just want to know if it exists or not.

Example: I want to be able to scan the entire D:\ to see if "Testing321.exe" exists on the drive. The problem I have is I'm able to scan something like "C:\Users\Dan\Desktop" but I'm unable to scan "C:" because I'm given an error related to insufficient permissions even though I have given the program full administrator permissions in the Manifest.

Error:

Unhandled exception. System.UnauthorizedAccessException: Access to the path 'C:\Documents and Settings' is denied. at System.IO.Enumeration.FileSystemEnumerator1.CreateRelativeDirectoryHandle(ReadOnlySpan1 relativePath, String fullPath) at System.IO.Enumeration.FileSystemEnumerator1.MoveNext() at System.Collections.Generic.LargeArrayBuilder1.AddRange(IEnumerable1 items) at System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source) at System.IO.Directory.GetFiles(String path, String searchPattern, SearchOption searchOption) at Alpha.Program.Main(String[] args) in C:\AlphaSS\Alpha\Alpha\Program.vb:line 80

Code:

Dim Path As String
            Console.WriteLine("Enter Directory to search [Phantom DLL]: ")
            Path = Console.ReadLine()

            Dim FolderPath = Path
            For Each filePath In Directory.GetFiles(FolderPath,
                                            "RXEXV2.dll",
                                            SearchOption.AllDirectories)

                If filePath IsNot Nothing Then
                    Console.WriteLine("DETECTED: Phantom Menu DLL Found: " & filePath)
                Else
                    Console.WriteLine("Nothing Detected")
                End If

This code above is essentially an idea I have in mind which will scan a player's computer for certain (cheat) files and if those files are found it will output it back to the console.

If anyone has a solution to this, please let me know!

Capatino
  • 11
  • 2
  • If you can target .NET Standard 2.1 (meaning your .NET implementation is .NET Core 3.0 or higher, and not .NET Framework 4.8 which implements only .NET Standard 2.0), then you can use [Directory.EnumerateFiles(string, string. EnumerationOptions)](https://learn.microsoft.com/en-us/dotnet/api/system.io.directory.enumeratefiles?view=netstandard-2.1#System_IO_Directory_EnumerateFiles_System_String_System_String_System_IO_EnumerationOptions_). See [this answer](https://stackoverflow.com/a/61868218/3791245) for info. – Sean Skelly Nov 30 '20 at 23:53
  • 1
    Unfortunately there are always files/directories you cannot access, even if your app has admin privileges. You will have to handle the UnauthorizedAccessException. If you search StackOverflow, you can find other answers with recursive attempts at this problem. – Sean Skelly Nov 30 '20 at 23:54
  • How would I implement that into my code though because I'm not using the same language. – Capatino Dec 01 '20 at 11:14
  • Towards the top-right of the documentation page (next to something that says 'Bookmark'), there is a way to switch between the languages, so you can show the same sample code in VB. The real question is whether you can have your project target .NET Standard 2.1, or if you are targeting .NET Framework. If you can't target .NET Standard 2.1, then the option in the link above won't help. – Sean Skelly Dec 01 '20 at 17:58
  • To be honest all of that just went straight over my head. I only have basic knowledge with VB.NET. I can't believe it's so difficult to search a Drive (probs just me) – Capatino Dec 01 '20 at 23:17
  • Try searching StackOverflow for other answers to this question. Here's [an answer that looks interesting](https://stackoverflow.com/a/18889820/3791245), and is even in VB. Just be careful about how the UnauthorizedAccessException is handled. If you Catch it in the wrong place, you may end up skipping files in a directory you have access to, or skipping other directories you have access to. – Sean Skelly Dec 02 '20 at 18:33
  • Just looked into this - doesn't seem to actually do anything. I changed "*.exe" to what I'm searching for and nothing is outputted. – Capatino Dec 02 '20 at 20:45

0 Answers0