Is accessing USB from a web application for cross browser cross OS possible at all?

I am wondering if there is a way we can achieve this. I heard different things about Silverlight 4, JavaScript or ActiveX control, but I have not seen any demo of code for any of them.

Is there a web component that is available or how can I write one?

We really like to capture a client’s USB drive via the Web and read/write data on it. This has to work for any operating system in any web browser.

What about WPF in browser mode? I read that I can host my WPF applications inside browser and sort of like smart client.

Here is a great example of doing this via Silverlight 4, but the author mentions about possibility of accessing USB on Mac via:

  1. Enable executing AppleScript scripts.
    This option will let us have the same amount of control on a Mac machine as we do on a Windows machine.

  2. Add an overload to ComAutomationFactory.CreateObject() that calls the “Tell Application” command under the scenes and gets a AppleScript object.
    This option would work extremely well for Microsoft Office automation. For any other operating system feature, you’ll have to code the OS access twice.

I did not quite understand it. Has any tried this?

Answer

If you’re willing to introduce a dependency on Flash (10), you can use the FileReference class to get access to one file at a time, first for reading using the browse method, then for writing using the save method.

Note that for security reasons, each call to these methods must be triggered as a result of user input (e.g. clicking a button), and each time they are called an OS-specific File Open/Save As dialog box is displayed.

There’s a video tutorial which gives some sample code for editing a text file (load + save) directly in Flash, without needing any server-side help. It should be enough to get you started in the right direction.