TeamMentor.CoreLib.TM_Xml_Database_ExtensionMethods_Library_Files.upload_File_to_Library C# (CSharp) Method

upload_File_to_Library() private method

private upload_File_to_Library ( this tmFileStorage, System.Guid libraryId, string filename, byte fileContents ) : bool
tmFileStorage this
libraryId System.Guid
filename string
fileContents byte
return bool
        public static bool upload_File_to_Library(this TM_FileStorage tmFileStorage, Guid libraryId, string filename, byte[] fileContents)
        {
            UserRole.Admin.demand();
            var targetLibrary = tmFileStorage.tmXmlDatabase().tmLibrary(libraryId);
            if (targetLibrary.notNull())
            {
                var targetFolder = tmFileStorage.xmlDB_Path_Library_RootFolder(targetLibrary)
                                                .pathCombine("_Images")
                                                .createDir();
                var targetFile = targetFolder.pathCombine(filename.safeFileName());
                return fileContents.saveAs(targetFile).fileExists();

            }
            return false;
        }
TM_Xml_Database_ExtensionMethods_Library_Files