public async Task <DocumentReference> Duplicate(IFileSystem fs) { var baseName = Name; if (!baseName.EndsWith("Copy", StringComparison.Ordinal)) { baseName = baseName + " Copy"; } var directory = Path.GetDirectoryName(File.Path); LocalFileAccess local = null; var contents = ""; try { local = await File.BeginLocalAccess(); var localPath = local.LocalPath; contents = System.IO.File.ReadAllText(localPath); } catch (Exception ex) { Debug.WriteLine(ex); } if (local != null) { await local.End(); } var ext = Path.GetExtension(File.Path); var dr = await New(directory, baseName, ext, fs, dctor, contents); dr.IsNew = false; return(dr); }
public async Task Close() { if (Document == null) { throw new InvalidOperationException("Trying to Close an unopened document"); } await Document.CloseAsync(); Document = null; if (local != null) { await local.End(); local = null; } }