下面的代碼是嘗試從共享點獲取(下載)文件。 如果我在我的本地版本上嘗試這個,它就像一個魅力。我可以選擇文檔庫中的所有項目。SharePoint 365的行爲與本地版本不同
有幾種方法我嘗試過,如果你喜歡,我可以在這裏發佈一些。我可以下載損壞的文件,但即使鏈接錯誤。 如果我在Office 365中的TeamSite上嘗試此操作,我會遇到一個例外情況,即我的鏈接錯誤。但我指的是同一個站點(而不是localhost/dev/im,指的是http://mysite.com/TeamSite/dev/)。任何想法有什麼不同?微軟是否阻止了某些東西,因此不允許外部連接?
private void btnDownload_Click(object sender, EventArgs e)
{
if (comboBox1.Items.Count > 0 && comboBox1.SelectedIndex != -1)
{
SaveFileDialog dialog = new SaveFileDialog();
dialog.ShowDialog();
using (SPSite site = new SPSite("http://localhost/dev/"))
{
using (SPWeb web = site.OpenWeb())
{
SPFolder myLibrary = web.Folders["Management"];
foreach (SPFile file in myLibrary.Files)
{
if (file.Name == comboBox1.SelectedItem.ToString())
{
byte[] bytes = file.OpenBinary();
try
{
FileStream fs = new FileStream(dialog.FileName, FileMode.Create, FileAccess.ReadWrite);
BinaryWriter bw = new BinaryWriter(fs);
bw.Write(bytes);
bw.Close();
MessageBox.Show("File downloaded to: " + dialog.FileName);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
}
}
else
{
MessageBox.Show("Select file to download");
}
}
這是異常消息:
The Web application at http://www.gtest.nl/TeamSite/ could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application.
Microsoft不支持此操作。我們公司也試圖得到類似於這個解決方案的東西。我們不得不中止這個項目,因爲當前版本的Office365不支持這個問題。 –