Accessing a Java.IO.FileDescriptor with System.IO.FileStream

RahRah USMember ✭✭
edited September 2013 in Xamarin.Android

Hi,

I am developing an Android accessory app that will implement MS Synchronization Libraries.

When I connect my device to a windows machine via USB, I end up with a FileDescriptor.

Using the Java.IO classes, I can write to and read from this FileDescriptor with FileOutputStream and FileInputStream.

However, MS Sync libraries require a System.IO.Stream with which to read and write stuff.

My questions are:
Simple: Can I cast a Java.IO.OutputStream or Java.IO.InputStream to a System.IO.Stream?
If so, how because (Stream)outpustream does not work.
More difficult: Can I access the FileDescriptor's channel using MS IO classes such as System.IO.FileStream?

I know this will involve advanced JNI calls but I really need some kind of direction here.

I tired newing a FileStream using the FileDescriptor's Handle but I get an Invalid IntPtr exception.

Posts

  • FZelleFZelle DEMember ✭✭✭

    I end up with a FileDescriptor.

    How do you connect and end up with one?

    Can I cast a Java.IO.OutputStream or Java.IO.InputStream to a System.IO.Stream?

    No, there is no typecast for that.

  • RahRah USMember ✭✭

    How do you end up with one?

    Like this:
    ParcelFileDescriptor pfd = usbManager.OpenAccessory(accessory);
    FileDescriptor fd = pfd.FileDescriptor;

Sign In or Register to comment.