Page view counter
Sharing violation opening a file with OpenFileDialog - Can we change this?? Subscribe to this thread
Last post 07-28-2008 3:59 AM by Yi-Lun Luo - MSFT. 1 replies.
Sort Posts:
07-24-2008 11:25 AM
Sharing violation opening a file with OpenFileDialog - Can we change this??

 Good morning! I've recently ran into an issue with a sharing violation using the OpenFileDialog. Basically, we have the ability to import CSV data in our application. When I open Excel and create a CSV file, then save to disk and subsequently open it with Silverlight, I get a sharing violation and an exception is thrown. I only see two options for opening the file: "OpenRead" and "OpenText".

I assume that our hands are tied here and we can't tell the framework to open the file in manner thats safer. For instance, I can open the file with Notepad++ and it doesn't complain. The only difference I see is the options:

SL: Options:    Synchronous IO Non-Alert, Non-Directory File, Open No Recall
NOtepad++: Options:    Synchronous IO Non-Alert, Non-Directory File

So... does anyone have any experience with this? It seems that since it's a read only file open under ALL circusmtances, we should be able to open this file in this situation..

Cheers!

-Sean

 

CleverCoder

Loading...
Joined on 05-16-2008
Raleigh, NC, US
Posts 157
07-28-2008 3:59 AM
Marked as Answer
Re: Sharing violation opening a file with OpenFileDialog - Can we change this??

Hello, I think Office opens a file with the FILE_SHARE_WRITE flag, which means subsequent requests to this file must also include this flag, or the request will fail. Try to open the file in WordPad, and you'll also note an error. WordPad opens a file with the FILE_SHARE_READ flag only. However, Notepad, or your Notepad++, opens a file with both FILE_SHARE_READ and FILE_SHARE_WRITE flags, so the request succeeds. There's very little you can do in Silverlight to change this behavior. I've logged this as a feature request. But I can't assure you anything since the IO APIs are completely different on Mac, and we need to support both...

shanaolanxing - I'll transfer to the Windows Azure team, and will have limited time to participate in the Silverlight forum. Apologize if I don't answer your questions in time.

Yi-Lun Luo - MSFT

Loading...
Joined on 10-29-2007
Posts 2,747
Microsoft Communities