Reputation: 11
I have tried everything but I am not able to get path of pendrive.
Here is my code :
var deviceList = mUsbManager.DeviceList;
IEnumerator<UsbDevice> deviceIterator = deviceList.Values.GetEnumerator();
while (deviceIterator.MoveNext())
{
UsbDevice device = deviceIterator.Current;
var mPermissionIntent = PendingIntent.GetBroadcast(this.ApplicationContext, 0, new Intent(ACTION_USB_PERMISSION), 0);
UsbManager mUsbManager = (UsbManager)this.GetSystemService(Context.UsbService);
mUsbManager.RequestPermission(device, mPermissionIntent);
bool perm = mUsbManager.HasPermission(device);
if (perm)
{
Java.Lang.Process process = Runtime.GetRuntime().Exec("ls /storage/7EFA-0EB6");
BufferedReader buffer = new BufferedReader(new InputStreamReader(process.InputStream));
string listOfFiles = "";
string line;
while ((line = buffer.ReadLine()) != null)
{
listOfFiles += line + "\n";
}
txt.Text += listOfFiles;
var alrt = Toast.MakeText(this as Context, "\n" + process + "\n"+listOfFiles + "this Path ", ToastLength.Long);
alrt.SetGravity(Android.Views.GravityFlags.Center, 0, 0);
alrt.Show();
}
}
Further I am not able to use mount points defined by manufacturers. like :
/storage/UsbDriveA
/storage/USBstorage1
/storage/usbdisk
/storage/usbotg
/storage/UDiskA
/storage/usb-storage
/storage/usbcard
/storage/usb
as you can see here I have write it hard-coded.
I am stuck in this since 2 weeks.
I just need to copy some Image file from pen-drive and store it in app data.
Upvotes: 0
Views: 293