ASP:上传控件。上传到 SharePoint 文档库子文件夹并出现 FILE NOT FOUND 错误

发布于 2024-09-19 17:11:36 字数 1085 浏览 1 评论 0原文

RE: ASP:上传控件。上传到 SharePoint 文档库子文件夹和文件未找到错误

两个问题,显然不相关。

我有这样的子文件夹 /ApplicantDocuments/20 和 /ApplicantDocuments/21 (其中 20 和 21 是我的子文件夹,ApplicantDocuments 是我的库。

  1. 以下函数因找不到文件而出错,但我确认我正在发送完整的文件限定 System.IO.FileStream 的路径(即 c:\test.txt) content = System.IO.File.Open(documentFileName, System.IO.FileMode.Open);

  2. ; 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.

  1. 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);

  2. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

绻影浮沉 2024-09-26 17:11:36
string Lib = "ApplicantDocuments"; 
SPFolder destFolder = web.GetFolder(Lib);

我们有两个 SPWeb.GetFolder() 重载。 参见此处 一个采用 GUID,另一个采用 GUID接受包含文件夹的服务器相对 URL 的字符串。最好的方法是使用 GUID 获取文件夹。如果您想按名称获取文件夹,则也可以使用文件夹代码。

mydoclib = get reference to the doc lib here. then
SPFolder destFolder = mydoclib.rootFolder.SubFolders["20"];
string Lib = "ApplicantDocuments"; 
SPFolder destFolder = web.GetFolder(Lib);

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.

mydoclib = get reference to the doc lib here. then
SPFolder destFolder = mydoclib.rootFolder.SubFolders["20"];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文