ASP:上传控件。上传到 SharePoint 文档库子文件夹并出现 FILE NOT FOUND 错误
RE: ASP:上传控件。上传到 SharePoint 文档库子文件夹和文件未找到错误
两个问题,显然不相关。
我有这样的子文件夹 /ApplicantDocuments/20 和 /ApplicantDocuments/21 (其中 20 和 21 是我的子文件夹,ApplicantDocuments 是我的库。
以下函数因找不到文件而出错,但我确认我正在发送完整的文件限定 System.IO.FileStream 的路径(即 c:\test.txt) content = System.IO.File.Open(documentFileName, System.IO.FileMode.Open);
- ; p>即使它有效,查看代码,我也没有使用参数文件夹名称,我如何确保它上传到 ApplicantDocuments 的子文件夹 20 中?
,并且我正在运行 Windows 7。 /IE 8。
谢谢。
只是在测试环境中进行测试。一旦有效,将收紧代码。
[代码] 公共无效UploadDocumentToSite(字符串文件夹名称,字符串文档文件名称) { SPSite siteCollection = new SPSite("https://xxxxxx"); SPWeb web = siteCollection.OpenWeb(); //SPSite.AllowUnsafeUpdates = true; //Web.AllowUnsafeUpdates = true; string Lib = "申请人文档"; SPFolder destFolder = web.GetFolder(Lib); sendmail(文档文件名+" "+文件夹名); System.IO.FileStream 内容 = System.IO.File.Open(documentFileName, System.IO.FileMode.Open); destFolder.Files.Add(documentFileName, 内容, true); } [/代码]
RE: ASP:Upload control . Uploading into a SharePoint Document Library Subfolder and FILE NOT FOUND error
Two Issues, apparently unrelated.
I have subfolders like this /ApplicantDocuments/20 and /ApplicantDocuments/21 (where 20 and 21 are my subfolders and ApplicantDocuments is my library.
The below function is erroring with file not found, but I confirmed I'm sending the fully qualify path (i.e c:\test.txt) to System.IO.FileStream content = System.IO.File.Open(documentFileName, System.IO.FileMode.Open);
Even if it worked, looking at the code, I'm not using argument foldername. I'm passing 20 to the argument. How can I make sure it uploads into subfolder 20 of ApplicantDocuments?
The file is on my local client and I'm running Windows 7/ IE 8.
Thank you.
Just testing in test environment. Will tighten code once it works.
[code]
public void UploadDocumentToSite(string foldername, string documentFileName)
{
SPSite siteCollection = new SPSite("https://xxxxxx");
SPWeb web = siteCollection.OpenWeb();
//SPSite.AllowUnsafeUpdates = true;
//Web.AllowUnsafeUpdates = true;
string Lib = "ApplicantDocuments";
SPFolder destFolder = web.GetFolder(Lib);
sendmail(documentFileName+" "+foldername);
System.IO.FileStream content = System.IO.File.Open(documentFileName, System.IO.FileMode.Open);
destFolder.Files.Add(documentFileName, content, true);
}
[/code]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我们有两个 SPWeb.GetFolder() 重载。 参见此处 一个采用 GUID,另一个采用 GUID接受包含文件夹的服务器相对 URL 的字符串。最好的方法是使用 GUID 获取文件夹。如果您想按名称获取文件夹,则也可以使用文件夹代码。
We have two overloads of SPWeb.GetFolder(). See Here One takes GUID and the other takes string that contains the server-relative URL for the folder. The best way is to get the folder using GUID. If you want to get the folder by name then you can use the folder code as well.