1

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?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Zeus
  • 3,091
  • 6
  • 47
  • 60
  • ActiveX will work only on IE, javascript will never be able to do stuff like that for security reasons, don't really know about silverlight but my guess is that it is not possible, or at least i hope it isn't. – Shurdoof Dec 30 '10 at 18:01
  • I don't see how accessing a USB drive is any different from accessing the user's hard drive -- could you explain further? – Cameron Dec 30 '10 at 18:02
  • 2
    You can't access a user's hard drive either, so there is no real difference. – Diodeus - James MacFarlane Dec 30 '10 at 18:08
  • @Diodeus: Yeah, but the question is asking specifically about a USB device -- I'm wondering if there's some additional information that would help us answer the question – Cameron Dec 30 '10 at 18:13
  • you are right ...by business case was related to USB so I asked regarding USB access...I see that there are not many solutions out there to access USB on MAC using any of these technologies – Zeus Dec 31 '10 at 02:29

4 Answers4

4

Web browsers are deliberately isolated from the filesystem for security reasons. Only Java (not "Java Script"), Flash or browser plug-ins can accomplish this.

Diodeus - James MacFarlane
  • 112,730
  • 33
  • 157
  • 176
1

JavaScript cannot directly access your local disk (including a flash drive) for security reasons (would you really want any web site you look at to access, change, or even delete your files?), and ActiveX controls are IE-specific, so you should probably use a Java applet (not JavaScript). While Java's security policy normally does not allow access to local disks, signed applets can with the user's permission.

PleaseStand
  • 31,641
  • 6
  • 68
  • 95
0

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.

Cameron
  • 96,106
  • 25
  • 196
  • 225
  • @Ved: I've used this myself (and it works fine). I have not personally tested it on a Mac, but it's supposed to be cross-platform. – Cameron Dec 31 '10 at 14:08
  • @Ved: Hmm... I'd share my code but it's kinda convoluted ;-) I've added a link to a video tutorial. There are tons of articles if you search for 'Flash 10 FileReference'. If you run into trouble, ask another question and I (or somebody else) will be glad to help – Cameron Jan 05 '11 at 06:46
0

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

Zeus
  • 3,091
  • 6
  • 47
  • 60