![]() |
#1 |
Участник
|
mscrmblog: Update Filename or List Item name programmatically in SharePoint/WSS
Источник: http://mscrmblog.net/2010/03/09/upda...harepoint-wss/
============== As simple as it sounds, it ain’t simple. you would of thought the following would work: SPFile file = web.GetFile(strUrl);file.name = "mynameFilename.txt";file.Update();does not compute.. There are 2 ways I’ve found of accomplishing this: 1. using the SPFile.MoveTo method: string strUrl = "http://mysharepointsite/myolddocumentlibrary/Filename.txt";string newFileUrl = "http://mysharepointsite/mynewdocumentlibrary/mynewFilename.txt";SPSite site = new SPSite("http://mysharepointsite");SPWeb web = site.OpenWeb();web.AllowUnsafeUpdates = true; // this will stop it from erroring out due to security errorsSPFile file = web.GetFile(strUrl);file.MoveTo(newFileUrl);2. using File.Item["Name"] method.. string strUrl = "http://mysharepointsite/myolddocumentlibrary/Filename.txt";SPSite site = new SPSite("http://mysharepointsite");SPWeb web = site.OpenWeb();web.AllowUnsafeUpdates = true; // this will stop it from erroring out due to security errorsSPFile file = web.GetFile(strUrl);file.Item["Name"] = "NewFileName.txt";However i have found method 1 more reliable. hope this helps! Источник: http://mscrmblog.net/2010/03/09/upda...harepoint-wss/
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|
|
Опции темы | Поиск в этой теме |
Опции просмотра | |
|