private void ConvertMediaFile(MediaFile mediaFile, FileToSyncItemConfiguration path)
 {
     if (File.Exists(path.Destination.FullPath + PathUtils.Extension))
     {
         SyncItem parent = SyncItemProvider.GetSyncItem(path.Destination.FullPath + PathUtils.Extension);
         string   name   = String.IsNullOrEmpty(Path.GetFileNameWithoutExtension(mediaFile.Name))
             ? mediaFile.Name
             : Path.GetFileNameWithoutExtension(mediaFile.Name);
         string syncItemPath = Path.Combine(path.Destination.FullPath, name + PathUtils.Extension);
         if (File.Exists(syncItemPath))
         {
             SyncItem syncItem = SyncItemProvider.GetSyncItem(syncItemPath);
             if (mediaFile.Blob != syncItem.SharedValues[FileTemplateFields.Blob.FieldId])
             {
                 syncItem.AttachMediaFile(new FileInfo(mediaFile.FilePath));
                 syncItem = _serializationManager.UpdateStatistics(syncItem);
                 SyncItemProvider.SaveSyncItem(syncItem, syncItemPath);
             }
         }
         else
         {
             SyncItem item = _serializationManager.CreateSyncMediaItem(parent.ItemPath, path.Destination.Database, parent.ID, mediaFile.FilePath);
             SyncItemProvider.SaveSyncItem(item, syncItemPath);
         }
     }
 }
        private void ConvertFolder(FileToSyncItemConfiguration path)
        {
            if (!Directory.Exists(path.Destination.FullPath))
            {
                Directory.CreateDirectory(path.Destination.FullPath);
            }
            if (!File.Exists(path.Destination.FullPath + PathUtils.Extension))
            {
                SyncItem parent = SyncItemProvider.GetSyncItem(path.Destination.Parent + PathUtils.Extension);
                var      serializationFolder = _serializationManager.CreateSyncMediaFolder(new DirectoryInfo(path.Destination.FullPath).Name, path.Destination.Database, parent.ItemPath, parent.ID);
                SyncItemProvider.SaveSyncItem(serializationFolder, path.Destination.FullPath + PathUtils.Extension);
            }
            var mediaFiles = GetFiles(path.SourcePath).Where(NameIsNotNullOrEmpty);

            mediaFiles.ToList().ForEach(file => ConvertMediaFile(file, path));
            ConvertFolders(path);
        }