private int SynchonizeLocalAndRemoteFile(int fileId, string localFile, string remoteFile, List <string> remoteHashes)
        {
            int byteCount = 0;
            int index     = 0;

            byte[] buffer    = new byte[_chunkSize];
            int    chunkSent = 0;
            string localHash = String.Empty;
            BackupProgressEventArgs progressEventArgs = new BackupProgressEventArgs(0);

            Logger.Write(30013, "Synchronizing " + localFile + " with " + remoteFile, Logger.MessageSeverity.Debug);

            if (!base.IsCancelRequired)
            {
                using (FileStream fileToRead = FileSystem.GetOutlookFile(localFile))
                {
                    using (Stream fileToWrite = File.OpenWrite(remoteFile))
                    {
                        do
                        {
                            if (!base.IsCancelRequired)
                            {
                                byteCount = fileToRead.Read(buffer, 0, _chunkSize);
                                localHash = GetHash(buffer);
                                if (index >= remoteHashes.Count || localHash != remoteHashes[index])
                                {
                                    fileToWrite.Position = (long)index * _chunkSize;
                                    fileToWrite.Write(buffer, 0, byteCount);
                                    chunkSent++;
                                    if (index >= remoteHashes.Count)
                                    {
                                        _clientDb.InsertHash(fileId, index, localHash);
                                    }
                                    else
                                    {
                                        _clientDb.UpdateHash(fileId, index, localHash);
                                    }
                                }
                                index++;
                                progressEventArgs.Percent = (int)(fileToRead.Position * 100 / fileToRead.Length);
                                BackupProgress(progressEventArgs);
                            }
                            else
                            {
                                break;
                            }
                        } while (fileToRead.Position < fileToRead.Length);
                    }
                }
            }
            Logger.Write(30014, "Synchronizing finish. " + chunkSent + " chunk(s) have been sent to the remote destination", Logger.MessageSeverity.Debug);
            return(chunkSent);
        }