views:

18

answers:

1

I have a FileSyncProvider and I've written a custom implementation of the FullEnumerationSimpleSyncProvider. When files are synced from the FullEnumerationSimpleSyncProvider to the FileSyncProvider they are created correctly, but are zero bytes.

When synchronising in the other direction (FileSyncProvider as source) everything works as expected.

This is my IFileDataRetriever implementation. I've put breakpoints on the FileStream property setter and getter and the Size property of the Stream is always correct, never zero. The actual Stream itself is a MemoryStream, could that be causing any problems?

public class FileDataRetriever : IFileDataRetriever
{

    private System.IO.Stream fileStream;

    public string AbsoluteSourceFilePath
    {
        get
        {
            throw new NotImplementedException("AbsoluteSourceFilePath is not supported for this implementation of IFileDataRetriever");
        }
    }

    public FileData FileData { get; set; }

    public System.IO.Stream FileStream
    {
        get
        {
            return this.fileStream;
        }
        set
        {
            this.fileStream = value;
        }
    }

    public string RelativeDirectoryPath { get; set; }
}

Update:

If, as an experiment, I modify the code as below, a 5 byte file is created:

    public System.IO.Stream FileStream
    {
        get
        {
            return new MemoryStream(new byte[] { 1, 2, 3, 4, 5 });
        }
        set
        {
            this.fileStream = value;
        }
    }

So this tells me that it should work fine with a MemoryStream. If I put a breakpoint on the getter, it always looks valid whenever it's called - it has the correct size etc, not 0 as the size.

A: 

I've got it! All I needed to do was reset the Position of the Stream to 0. It was at the end of the stream, hence writing 0 bytes.

tjrobinson