private static Extract InitializeExtract(string filename, string customTempDirectoryPath = null, string customLogDirectoryPath = null) { if (String.IsNullOrWhiteSpace(filename)) { throw new ExtractInitializationException("Failed to initialize extract: Must provide a valid absolute path to an extract file"); } try { // Set environment variables used by the Extract API // If these are not set, the Extract API will utilize the current working directory if (!String.IsNullOrWhiteSpace(customTempDirectoryPath) && Directory.Exists(customTempDirectoryPath)) { Environment.SetEnvironmentVariable("TAB_SDK_TMPDIR", customTempDirectoryPath); } if (!String.IsNullOrWhiteSpace(customLogDirectoryPath) && Directory.Exists(customLogDirectoryPath)) { Environment.SetEnvironmentVariable("TAB_SDK_LOGDIR", customLogDirectoryPath); } ExtractAPI.initialize(); Directory.CreateDirectory(Directory.GetParent(filename).FullName); return(new Extract(filename)); } catch (Exception ex) { throw new ExtractInitializationException(String.Format("Failed to initialize extract '{0}': {1}", filename, ex.Message), ex); } }
public void Dispose() { try { if (extract != null) { extract.close(); ExtractAPI.cleanup(); } } catch { } }