public override int AddOrUpdateFile(FileInfo objFile, byte[] content, bool contentOnly) { var objFolder = FolderManager.Instance.GetFolder(objFile.FolderId); if (objFolder != null) { if (content != null && content.Length > 0) { using (var objStream = new MemoryStream(content)) { if (objFile.FileId > 0) { var toReturn = objFile.FileId; if (!contentOnly) { toReturn = FileManager.Instance.UpdateFile(objFile, objStream).FileId; } //Todo: seems the updatefile does not have the proper call to that function. Should be registered as a bug. FolderProvider folderProvider = FolderProvider.Instance( ComponentBase <IFolderMappingController, FolderMappingController> .Instance .GetFolderMapping(objFolder.PortalID, objFolder.FolderMappingID) .FolderProviderType); folderProvider.UpdateFile(objFolder, objFile.FileName, objStream); return(toReturn); } else { return(FileManager.Instance.AddFile(objFolder, objFile.FileName, objStream).FileId); } } } else { if (objFile.FileId > 0) { var toReturn = objFile.FileId; if (!contentOnly) { toReturn = FileManager.Instance.UpdateFile(objFile).FileId; } return(toReturn); } else { return(FileManager.Instance.AddFile(objFolder, objFile.FileName, null).FileId); } } } return(-1); }