Hi all,
I used below powershell script to copy the xml file to my sharepoint 2013 site in the docLibraryUrlName location.
$webUrl = "https://wwwsp2013.abcd.org/mncde"
$docLibraryName = "Documents"
$docLibraryUrlName = "SharePointlib"
$localFolderPath = "C:\Users\mmmvdes\Desktop\xmfolder"
#Open web and library
$web = Get-SPWeb $webUrl
$docLibrary = $web.Lists[$docLibraryName]
$files = ([System.IO.DirectoryInfo] (Get-Item $localFolderPath)).GetFiles()
ForEach($file in $files)
{
#Open file
$fileStream = ([System.IO.FileInfo] (Get-Item $file.FullName)).OpenRead()
#Add file
$folder = $web.getfolder($docLibraryUrlName)
write-host "Copying file " $file.Name " to " $folder.ServerRelativeUrl "..."
$spFile = $folder.Files.Add($folder.Url + "/" + $file.Name, [System.IO.Stream]$fileStream, $true)
write-host "Success"
#Close file stream
$fileStream.Close();
}
#Dispose web
$web.Dispose().
when run the script it is showing below error
Copying file VisualSPHelpItems.xml to /mncde/SharePointlib ...
Exception calling "Add" with "3" argument(s):
"<nativehr>0x80070003</nativehr><nativestack></nativestack>There is no file
with URL 'https://wwwsp2013.abcd.org/mncde/SharePointlib /abcde.xml' in this Web."
At line:8 char:5
+ $spFile = $folder.Files.Add($folder.Url + "/" + $file.Name,
[System.IO.Strea ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DirectoryNotFoundException.
Please help.How to resolve this.Thanks in advance.
Regards,
Praveen