I have a file on a external device
This PC\HERO4 Session\External Memory\DCIM\101GOPRO
. Is there a way I can read this file in c# using File.OpenRead("This PC\HERO4 Session\External Memory\DCIM\101GOPRO")
because when I tried to my desktop WPF app just adds the execution path and fails with FileNotFoundException
.
Thanks
Asked
Active
Viewed 146 times
0

Clemens
- 123,504
- 12
- 155
- 268

Marko Stojkov
- 16
- 1
-
"This PC" isn't an actual path on the file system. This other question might help, but it's not an exact duplicate because they're showing a folder browser: https://stackoverflow.com/questions/33331667/cant-get-directory-from-external-device Still, it gives you an example of what kind of path you actually need. – Joel Coehoorn Feb 02 '22 at 16:03
1 Answers
0
\
is a special symbol.
You can use \\
in string: File.OpenRead("This PC\\HERO4 Session\\...")
or
@
before the string File.OpenRead(@"This PC\HERO4 Session\...")

Preslav Tsenov
- 163
- 2
- 9
-
I tried this approach many times, but as i said when i try to open a file from external drive and the path does not start with a partition like C: or D: then my wpf app just adds the execution path at the start and throws exception – Marko Stojkov Feb 02 '22 at 15:42