开发者

Opening already opened file on Windows CE

开发者 https://www.devze.com 2023-03-11 06:53 出处:网络
I have annoying problem with files. I develop soft on Windows CE which works with another piece of hardware. This hardware have physical memory (like pendrive) 开发者_StackOverflowand this pendrive is

I have annoying problem with files. I develop soft on Windows CE which works with another piece of hardware. This hardware have physical memory (like pendrive) 开发者_StackOverflowand this pendrive is visible from my device. Now I want to open one txt file on this memory and edit it. I know that that other piece of hardware opens that file all the time and monitore it.

I have little Notepad program which I downloaded, I can use it to edit that file anytime I want and hardware response in correct way. But if I want to open and edit that file from my program I get UnauthorizedAccessException. I know that this file is opened by another hardware but that notepad gets its job done so it is possible. I was trying many combinations to open file:

simple one:

TextWriter writer = new StreamWriter("path");

another:

using (var fs = new FileStream(path, FileMode.Open, 
                    FileAccess.ReadWrite, FileShare.ReadWrite))
{
    TextWriter writer = new StreamWriter(fs);
    ...
}

And I tried few combinations of FileMode and FileAccess and FileShare values. Now what should I do?

0

精彩评论

暂无评论...
验证码 换一张
取 消