【发布时间】:2012-10-03 12:11:05
【问题描述】:
下面的代码尝试从共享点获取(下载)文件。 如果我在我的本地版本上尝试这个,它就像一个魅力。我可以选择文档库中的所有项目。
我尝试了几种方法,如果您愿意,我可以在这里发布其中的一些方法。我可以下载损坏的文件,但即使链接错误。 如果我在 Office 365 中的 TeamSite 上尝试此操作,则会收到链接错误的异常。但我指的是同一个站点(而不是 localhost/dev/im 指的是http://mysite.com/TeamSite/dev/)。知道有什么区别吗? Microsoft 是否阻止了某些东西,因此不允许外部连接?
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.
【问题讨论】:
-
微软不支持这个。我们公司也试图获得与此解决方案类似的东西。我们不得不终止该项目,因为当前版本的 Office365 不支持此问题。