private void SaveAsFile(Stream s)
{
XPathNavigator comment = commentToUUID.ContainsKey(Comments.SelectedNode) ? commentToUUID[Comments.SelectedNode].Item2 : null;
if (comment == null) throw new Exception("Comment not found");
var commentbody = comment.SelectSingleNode("body").ToString();
var commenttype = comment.SelectSingleNode("content-type").ToString();
if (commenttype.StartsWith("text/"))
{
byte[] towrite = Encoding.UTF8.GetBytes(commentbody);
s.Write(towrite, 0, towrite.Length);
}
else
{
byte[] towrite = Convert.FromBase64String(commentbody);
s.Write(towrite, 0, towrite.Length);
}
}
public TemporarySaveFile(IssueDetail form) { uuid_xpath comment = form.commentToUUID.ContainsKey(form.Comments.SelectedNode) ? form.commentToUUID[form.Comments.SelectedNode] : null; var ext = MIMETypesDictionary.ContainsKey(form.DraggableIcon.Items[0].Text) ? MIMETypesDictionary[form.DraggableIcon.Items[0].Text] : "bin"; string tempfilepath = Path.GetTempPath() + "BEurtle"; tempfilename = tempfilepath + @"\comment-" + (comment!=null ? comment.Item1.ToString() : "new") + "." + ext; if (!Directory.Exists(tempfilepath)) Directory.CreateDirectory(tempfilepath); data = new FileStream(tempfilename, FileMode.Create, FileAccess.ReadWrite, FileShare.Delete | FileShare.ReadWrite); form.SaveAsFile(data); data.Seek(0, SeekOrigin.Begin); }