public bool InstallSamplePackage(string packageFilePath) { if (!File.Exists(packageFilePath)) { return(false); // do nothing } //get temporary directory to extract the package var tempDirectory = _localFileProvider.GetTemporaryDirectory(); try { //first extract the zip _localFileProvider.ExtractArchive(packageFilePath, tempDirectory); //now copy the image files to the uploads directory var wwwroot = ServerHelper.MapPath("~/", true); var uploadsDirectory = _localFileProvider.CombinePaths(wwwroot, "content", "Uploads"); var sourceFilesDirectory = _localFileProvider.CombinePaths(tempDirectory, "images"); var files = _localFileProvider.GetFiles(sourceFilesDirectory); foreach (var file in files) { //copy the file var fileName = _localFileProvider.GetFileName(file); _localFileProvider.CopyFile(file, Path.Combine(uploadsDirectory, fileName)); } //sql path if any var sqlFile = _localFileProvider.CombinePaths(tempDirectory, "data.sql"); if (File.Exists(sqlFile)) { var sql = _localFileProvider.ReadAllText(sqlFile); //execute the query file using (EntitySet.Query(sql, null)) { } } //delete the temporary directory _localFileProvider.DeleteDirectory(tempDirectory, true); return(true); } catch (Exception ex) { _logger.Log <InstallationService>(LogLevel.Error, ex.Message, ex); return(false); } finally { _localFileProvider.DeleteDirectory(tempDirectory, true); } }