Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

((Stream)OutputStream).CanSeek is true, but Seek() throws an exception #31

Open
mikemor76 opened this issue Sep 9, 2019 · 0 comments
Open

Comments

@mikemor76
Copy link

    private void btnTest_Click(object sender, EventArgs e)
    {
        var url = $"smb://{txtPath.Text}/test.test";
        var file = new SmbFile(url, _auth);
        file.CreateNewFile();
        var ostream = file.GetOutputStream();
        ostream.Write(123);
        ostream.Write(123);
        var stream = (Stream)ostream;
        Debug.WriteLine(stream.CanSeek); //stream.CanSeek is true
        stream.Seek(0, SeekOrigin.Begin); //strangely enough this works
        stream.Seek(0, SeekOrigin.End); //throws an exception:

//Exception thrown: 'System.NullReferenceException' in SharpCifs.Std.dll
//An unhandled exception of type 'System.NullReferenceException' occurred in SharpCifs.Std.dll
//Object reference not set to an instance of an object.
StackTrace:
at SharpCifs.Util.Sharpen.WrappedSystemStream.get_Length()
at SharpCifs.Util.Sharpen.WrappedSystemStream.Seek(Int64 offset, SeekOrigin origin)
at NetShareTest.Form1.btnTest_Click(Object sender, EventArgs e)
}

Looks like the CanSeek property of Stream object which is returned by implicit operator Stream should return false always. Or Seek() method should work properly and should not throw any exception.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant