我想在Xamarin打開一個Word文檔表格PCL利用Syncfusion例如下面的代碼:誤差的HTTPRequest和DocIO
using System.Net;
using System;
using System.IO;
using Syncfusion.DocIO.DLS;
using Syncfusion.DocIO;
public void CreateWordDoc()
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://valufy.file.core.windows.net/valufyfiles/ValufyReportWordTemplate.docx");
HttpWebResponse response = await (HttpWebResponse)request.GetResponse(); <----- FIRST ERROR HERE
Stream stream = response.GetResponseStream();
//Converts it to byte array
byte[] buffer = ReadFully(stream, 32768);
//Stores bytes into the memory stream.
MemoryStream ms = new MemoryStream();
ms.Write(buffer, 0, buffer.Length);
ms.Seek(0, SeekOrigin.Begin);
stream.Close();
//Creates a new document.
WordDocument document = new WordDocument();
//Opens the template document from the MemoryStream.
document.Open(ms, FormatType.Doc);
//Saves and closes the document
document.Save("Sample.docx", FormatType.Docx); <---- SECOND ERROR HERE
document.Close();
}
我收到以下錯誤:
- ErrorCS1061'HttpWebRequest'不包含'GetResponse'的定義,並且沒有找到接受第一個 參數類型'HttpWebRequest'的擴展方法'GetResponse'可以找到(你是否缺少使用指令的 或sembly 參考)ValufyC:\ Users \用戶sreesun \ OneDrive \項目\ 2Valufy \ 2Valufy_2Valufy \數據\ Export.cs20Active
- ErrorCS1503Argument 1:不能從 '字串' 轉換爲「System.IO.Stream'ValufyC:\用戶\ sreesun \ OneDrive \項目\ 2Valufy \ 2Valufy_2Valufy \ DATA \ Export.cs48Active
任何建議將是有益的。 GetResponse()方法是HttpWebRequest類的公共方法,我無法弄清楚它爲什麼會出錯。