|
Can you share a local file for reading? I know, that I can use an overloading with Stream parameter, but default behavior is strange. I'm using the following code:
If you uncomment line "var destination = new FileStream(…" (and comment "var destination = destinationFile;"), the test stream opens successfully. |
|
It turned out we were using File.Create in the GetFile method, and apparently this implies FileShare.None, which was indeed an oversight that resulted in strange behavior. Thanks for letting us know about this! We will definitely fix it for the next release. Sorry for inconvenience! |
|
Update: This turned out not to be the answer to Fred's question (see the other answer), but we are keeping it because someone else might still find it useful later. Short answer: You have to specify FileShare.ReadWrite when opening the currently-downloaded file for reading. It's a feature of the OS and there is no way around it. Long answer: GetFile/BeginGetFile methods actually do share the local file for reading. This is how we open it:
However, you probably tried accessing the file using a code like this:
or this:
and it failed. As you can see, this fails even though we did share the file for reading. But this is not Rebex issue - identical behavior can be reproduced using the following simple code:
Why does this fail? Because you have to specify And indeed, the following code works fine:
It might seem a bit odd that File.OpenRead can't be used in this case and many classes that rely on it fail, but there is nothing we can do about that. Apparently, this is a feature of the filesystem itself. Please, see my code sample. I'm using "Rebex SFTP for .NET - Trial Version" 2.0.3854.0
(23 Jul '10, 07:28)
_FRED_
Thanks, it looks you are right!
(23 Jul '10, 09:59)
Lukas Pokorny ♦♦
|