[英]How to move files with metadata in SharePoint?
I have written some code that copies files and their metadata to a new URL. 我编写了一些代码,将文件及其元数据复制到新的URL。 But for some reason it's only copying metadata for Word and Excel files.
但是由于某种原因,它只是复制Word和Excel文件的元数据。 Anything non-microsoft, like PDFs do not get their metadata copied.
任何非Microsoft的内容(例如PDF)都不会复制其元数据。 My code is below, does anyone see anything I should change?
我的代码在下面,有人看到我应该更改的内容吗?
Also, this code worked for PDFs when it ran under 2007... 此外,该代码在2007年下运行时适用于PDF。
static void CopyFileWithHistoryCrossSite(SPFile sourceFile, SPFolder destination, string destinationUrl)
{
byte[] binFile;
binFile = sourceFile.OpenBinary();
destination.Files.Add(destinationUrl, binFile, true);
}
This code will not "copy metadata" in destination, the metadata will be recreated based on the stream of the file's stream (it is called "property promotion", see http://msdn.microsoft.com/en-us/library/aa979617.aspx ). 此代码不会在目标位置“复制元数据”,而是根据文件流的流来重新创建元数据(这称为“属性提升”,请参阅http://msdn.microsoft.com/zh-cn/library/ aa979617.aspx )。
Try SPFile.CopyTo/MoveTo as I think they may copy metadata. 尝试SPFile.CopyTo / MoveTo,因为我认为他们可以复制元数据。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.