1

I am trying to use NTFS to search files from my drive, for which I faced the attached exception while trying to create object of RAWDiskLibrary. I have C, D, E drives and having this issue while I select any of the drives. Please help me in this regard.

Exception details: Code: const char driveLetter = 'E'; RawDisk disk = new RawDisk(driveLetter); Exception:

                System.ArgumentException
                HResult=0x80070057
                Message=Invalid diskName: \\.\E:
               `enter code here` Source=RawDiskLib

Thanks

https://i.stack.imgur.com/VlsgK.jpg

Adeel Kamran
  • 103
  • 7
  • 1
    Please do not post screenshots of your code and/or error messages (something to read: [Why not upload images of code on SO when asking a question?](https://meta.stackoverflow.com/a/285557/2819245), [An image of your code is not helpful](http://idownvotedbecau.se/imageofcode) and [Pictures of exceptions are not helpful](http://idownvotedbecau.se/imageofanexception/)). –  Jan 06 '19 at 20:02
  • Does it work for C: and D:? If only E: is failing, verify that E: actually is a disk (i don't know whether RAWDiskLibrary can work with DVD drives, network shared folders mounted as drive, or similar). –  Jan 06 '19 at 20:03
  • It does for C and D as well. I have F drive as DVD so that is not the case. – Adeel Kamran Jan 06 '19 at 20:05
  • Well, what exactly is E: then? –  Jan 06 '19 at 20:05
  • Its my local disk (Hard disk partition) just like C – Adeel Kamran Jan 06 '19 at 20:06
  • This is code I am running: You can find it on test app. https://github.com/LordMike/NtfsLib – Adeel Kamran Jan 06 '19 at 20:09
  • No, i am not going to look at that. Sorry. If you want people to look at the **relevant** code, put this relevant code in your question. (Don't dump all your code in the question, only put the minimal code necessary to illustrate or reproduce the error. Also see [ask] with a [mcve]) –  Jan 06 '19 at 20:13
  • okay I just shared incase you want to see the code. – Adeel Kamran Jan 06 '19 at 20:14
  • By the way, just to confirm: Are you running Windows 10? Googling around for 0x80070057 errors, there are several search results of variety of error reports with most of them concerning Windows 10... –  Jan 06 '19 at 20:15
  • No I am using windows 7. – Adeel Kamran Jan 06 '19 at 20:16
  • Can you otherwise access your E: partition normally (like, through Windows Explorer, for example)? –  Jan 06 '19 at 20:19
  • Yes I can access – Adeel Kamran Jan 06 '19 at 20:24
  • Now, i don't know if you already have any data on your E: partition, so my suggestion here might not so easy to do, but what if you delete and recreate the E: partition from scratch and try then again? (The error you got is a strong indicator that something in your OS with regard to its object/device namespaces is a bit wonky, so it is most likely not related to your C# program per-se) –  Jan 06 '19 at 20:28
  • Oh, also in case you have any anti-virus or other software that is intercepting I/O running, try turning them off and see whether it changes the outcome. Should be worth a try, even if i myself don't really believe it will help (if an AV software of similar would be the culprit, i would expect the same issue to happen for C: and D: too). –  Jan 06 '19 at 20:33
  • I tried the same code on different PC and got the same exception. So what do you think now that can cause the issue? – Adeel Kamran Jan 07 '19 at 09:20

2 Answers2

0

Try it first for ensure if E is a valid drive letter:

var drives = Utils.GetAllAvailableVolumes();

The full example is here EX

  • Yes I also add this line into code to check this and get C D and E as a drives. Then use this drives variable and still got the same issue. – Adeel Kamran Jan 06 '19 at 20:13
0

Run the visual studio as administrator. It will work :-).

Hassan Rahman
  • 4,953
  • 1
  • 34
  • 32