static void SaveFileCache(string file, string value) { try { Directory.CreateDirectory(Path.GetDirectoryName(file)); File.WriteAllText(file, value, Encoding.UTF8); } catch (Exception e) { FileLog.Error(string.Format("Error saving file: {0}, Error: {1}", file, e.Message)); } }
static string LoadFileCache(string file, string defaultValue) { string returnValue = defaultValue; try { if (File.Exists(file)) { returnValue = File.ReadAllText(file, Encoding.UTF8); } } catch (Exception e) { FileLog.Error(string.Format("Error loading file: {0}, Error: {1}", file, e.Message)); return(defaultValue); } return(returnValue); }
/// <summary> /// Get ShowTimes Trailer download directory /// </summary> /// <returns></returns> static string GetShowTimesTrailerDir() { string showTimesConfigFile = string.Empty; string trailerDir = string.Empty; FileLog.Debug("Getting ShowTimes Config location"); using (Settings xmlreader = new MPSettings()) { showTimesConfigFile = xmlreader.GetValueAsString(cShowTimes, cShowTimesConfigFile, string.Empty); } if (!string.IsNullOrEmpty(showTimesConfigFile)) { FileLog.Debug("Getting ShowTimes Trailer folder"); try { if (File.Exists(showTimesConfigFile)) { var xmlDoc = new XmlDocument(); xmlDoc.Load(showTimesConfigFile); var node = xmlDoc.SelectSingleNode("/ConfigurationSettings/TrailerFolder"); if (node != null) { trailerDir = node.InnerText; } } } catch (Exception e) { FileLog.Error("Unable to get trailer directory for ShowTimes plugin!: {0}", e.Message); } } return(trailerDir); }