Windows 8共享魅力

时间:2014-01-03 07:56:04

标签: email windows-8 windows-runtime windows-8.1 sharing

我有一个应该提供共享可能性的应用程序,所以这是我的代码:

DataRequestDeferral deferral = e.Request.GetDeferral();
var file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(@"Utils\shareappemail.html");
 var file2 = await Windows.Storage.ApplicationData.Current.LocalFolder.GetFileAsync("SCLogFile.txt");
 var stream = await file.OpenReadAsync();
 var rdr = new StreamReader(stream.AsStream());
 var contents = await rdr.ReadToEndAsync();
 DataPackage requestData = e.Request.Data;
 requestData.Properties.Title = "Bla";
 requestData.Properties.Description = "BlablaBla"; // The description is optional.
 requestData.SetHtmlFormat(HtmlFormatHelper.CreateHtmlFormat(contents));
 List<IStorageItem> imageItems = new List<IStorageItem>();
 imageItems.Add(file2);
 requestData.SetStorageItems(imageItems);
 deferral.Complete();

在我的开发者PC上,这个东西有用,文件正在附加。但是在我的平板电脑上它没有附加文件 - 为什么?

ADDITION!

这段代码附上一个文件,我把这句话弄清楚了://requestData.SetHtmlFormat(HtmlFormatHelper.CreateHtmlFormat(contents));

这件事让我抓狂!怎么样?为什么?我怎样才能获得HTML内容+附件

DataRequestDeferral deferral = e.Request.GetDeferral();
var file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(@"Utils\shareappemail.html");
var file2 = await Windows.Storage.ApplicationData.Current.LocalFolder.GetFileAsync("SCLogFile.txt");
var stream = await file.OpenReadAsync();
var rdr = new StreamReader(stream.AsStream());
var contents = await rdr.ReadToEndAsync();
DataPackage requestData = e.Request.Data;
requestData.Properties.Title = "Bla";
requestData.Properties.Description = "BlablaBla"; // The description is optional.
//requestData.SetHtmlFormat(HtmlFormatHelper.CreateHtmlFormat(contents));
List<IStorageItem> imageItems = new List<IStorageItem>();
imageItems.Add(file2);
requestData.SetStorageItems(imageItems);
deferral.Complete();

0 个答案:

没有答案