public static bool SaveString(string name, string data, string path, bool zip = false) { path = ADSFile.GetFullPatch(path); if (path.IsNullOrWhiteSpace()) { return(false); } try { if (zip) { ADSFile.Write(StringCompressor.Zip(data), path, name); } else { ADSFile.Write(data, path, name); } } catch (Exception ex) { Output.WriteException(ex); return(false); } return(true); }
public static string LoadString(string name, string path = null, bool unzip = false) { path = ADSFile.GetFullPatch(path); string data = null; if (path.IsNullOrWhiteSpace()) { return(data); } try { if (unzip) { data = StringCompressor.UnZip(ADSFile.Read(path, name)); } else { data = ADSFile.Read(path, name); } } catch (Exception ex) { Output.WriteException(ex); data = null; } return(data); }
/// <summary> /// Method called when an alternate data stream must be read from. /// </summary> /// <param name="file">The fully qualified name of the file from which /// the ADS data will be read.</param> /// <param name="stream">The name of the stream within the "normal" file /// from which to read.</param> /// <returns>The contents of the file as a string. It will always return /// at least a zero-length string, even if the file does not exist.</returns> public static string Read(string file, string stream) { return(System.Text.Encoding.ASCII.GetString(ADSFile.ReadBytes(file, stream))); }
/// <summary> /// The static method to call when data must be written to a stream. /// </summary> /// <param name="data">The string data to embed in the stream in the file</param> /// <param name="file">The fully qualified name of the file with the /// stream into which the data will be written.</param> /// <param name="stream">The name of the stream within the normal file to /// write the data.</param> /// <returns>An unsigned integer of how many bytes were actually written.</returns> public static uint Write(string data, string file, string stream) { byte[] barData = System.Text.Encoding.ASCII.GetBytes(data); return(ADSFile.WriteBytes(barData, file, stream)); }