Vestibulum et metus cursus in neque custodiam quid volo facere videtur, Ego figuratur ego ita scriberet.
Ego fuerit faciens multus of vicis susceptor debugging week vel duos in novissimo. The ER is defined against a document library. The individual items in the document library are tightly related to their parent folders. Ita, I am always getting the folder of the item for various manipulations. While debugging, EGO necessarius ad update metadata a folder pro certo scio item cujus ID.
Hic 'a console parum application (currere in server cogitavit ruris) quod duae allegationes: Item ID: et de pretio agri dare, "Approval Status". It hard codes a lot of stuff and has no error checking.
Codex suspicit duram site coded, gets a hard coded document library and then finds the indicated item. It then finds the parent folder of that item and assigns the status value.
The key lesson here for me is that SPItem doesn’t get you access to the folder. You need to use SPListItem.File.
Censura qui curat offerre folder vel ut rem melius suadet, commodo licentia a ineo.
<Codicem>
usura System; usura System.Collections.Generic; usura System.Text; usura Microsoft.SharePoint; usura System.Collections; Spatium nominale Conchango { /// <Summary> /// </Summary> genus ManualFolderUpdate { static Irrita Main(filum[] args) { filum msh = "ManualFolderUpdate (v1.0): "; // msh = "Message Header" Consolandum.WriteLine(msh + "Starting up. Last modified on 08/04/08 sum."); filum url = http://localhost/xyzzy; usura (SPSite oSPSite = novum SPSite(url)) { usura (SPWeb oSPWeb = oSPSite.OpenWeb()) { SPList docLib = oSPWeb.Lists["Documents"]; Consolandum.WriteLine(msh + "Got the document library."); Consolandum.WriteLine(msh + "Doc lib item count: [" + docLib.ItemCount + "]."); int FolderID = 0; filum NewStatus = "Xyzzy"; FolderID = System.Convoco.ToInt32(args[0].ToString()); Consolandum.WriteLine("Seeking folder for item: [" + FolderID + "]."); SPListItem li = docLib.GetItemById(FolderID); SPFolder thisItemFolder = li.File.ParentFolder; Consolandum.WriteLine(msh + "Got the parent folder."); NewStatus = args[1].ToString(); Consolandum.WriteLine("Setting status to [" + NewStatus + "]."); Consolandum.WriteLine("Press return to commit the update or CTRL-C to abort."); Consolandum.ReadLine(); thisItemFolder.Item["Approval Status"] = NewStatus; thisItemFolder.Item.Update(); Consolandum.WriteLine(msh + "Finished updating the folder. Exeunt."); } // usura SPWeb } // usura SPSite Consolandum.WriteLine(msh + "Finished."); } // Main } // classis foldersync } // Spatium nominale
</Codicem>
</finem>