public async void WriteAsync(string destination, string content, FunctionInstance callback) { var fullPath = Path.Combine(BaseFolder, destination); var directory = Path.GetDirectoryName(fullPath); if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } using (var sw = new StreamWriter(fullPath)) { foreach (var c in content) { await sw.WriteAsync(c); } } callback.Run(); }
public async void ReadAsync(string path, FunctionInstance callback) { char[] result; var builder = new StringBuilder(); var fullPath = Path.Combine(BaseFolder, path); using (var sr = new StreamReader(fullPath)) { result = new char[sr.BaseStream.Length]; await sr.ReadAsync(result, 0, (int)sr.BaseStream.Length); } foreach (var c in result) { if (char.IsLetterOrDigit(c) || char.IsWhiteSpace(c)) { builder.Append(c); } } callback.Run(Engine.CreateString(builder.ToString())); }