using System.IO; using System.Windows.Forms; using WindowsLive.Writer.Api; namespace LiveWriterForm { [WriterPluginAttribute ("4f693db8-669c-4a05-ae64-1e73c4c81d10", "Insert Text From File Plugin", PublisherUrl = "http://blog.benhall.me.uk", Description = "This plugin allows you to select a file and insert the contents into the blog post")] [InsertableContentSourceAttribute("From File...", SidebarText = "From File...")] public class InsertTextFromFilePlugin : ContentSource { public override DialogResult CreateContent(IWin32Window dialogOwner, ref string content) { OpenFileDialog ofd = new OpenFileDialog(); DialogResult result = ofd.ShowDialog(); if(result == DialogResult.OK) { StreamReader sr = new StreamReader(ofd.FileName); string text = sr.ReadToEnd(); sr.Close(); text = text.Replace("\r\n", "
"); content = text; } return result; } } }