0
I持つドキュメントライブラリにファイルを置き、次のコード:のSharePoint 2013ファイルのアップロードは、ドキュメントライブラリにフォルダに
public static void UploadFile(string siteURL, string libraryName, string file)
{
String fileToUpload = file;
String sharePointSite = siteURL;
String documentLibraryName = libraryName;
using (SPSite oSite = new SPSite(sharePointSite))
{
using (SPWeb oWeb = oSite.RootWeb)
{
if (!System.IO.File.Exists(fileToUpload))
throw new FileNotFoundException("File not found.", fileToUpload);
SPFolder myLibrary = oWeb.Folders[documentLibraryName];
// Prepare to upload
Boolean replaceExistingFiles = true;
String fileName = System.IO.Path.GetFileName(fileToUpload);
FileStream fileStream = System.IO.File.OpenRead(fileToUpload);
// Upload document
SPFile spfile = myLibrary.Files.Add(fileName, fileStream, replaceExistingFiles);
// Commit
myLibrary.Update();
}
}
}
は、私が「ナビ」と呼ばれるそのライブラリ内のフォルダの中にファイルを配置したいです私はこれを実現させる方法がわかりません。私は試しましたが、それをフォルダに入れることはできません。
SPFolder myLibrary = oWeb.Folders[documentLibraryName].SubFolders["Nav"];
アイデア:
これは私の最新の試みでしたか?