简体   繁体   中英

c# - GetFiles() in DirectoryInfo class on phone device

I am trying to get a list of files from my samsung phone when plugged in via usb on the computer. the code below return file not found exception due to part of path not found. However, the source path can be found on the file explorer.

string source = @"SAMSUNG\Phone";
DirectoryInfo dir = new DirectoryInfo(source);

dir.GetFiles("*.*", System.IO.SearchOption.AllDirectories);

Example of how the cellphone device display look similar to this:

Example: screenshot of file explorer

The error message listed my project name path\\SAMSUNG\\phone, which is weird. I tried this with regular USB thumbdrive that have an actual drive name and it works. Any advice help. Thank you!

If you just put SAMSUNG\\Phone it is treated as a relative path (relative to the current working directory for your application). If you meant to access a UNC share , use \\\\SAMSUNG\\Phone .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM