Opening already opened file on Windows CE
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?
精彩评论