விரைவான மற்றும் எளிதான: SPItemList என்ற SPFolder கிடைக்கும்

நான் என்ன செய்யவேண்டும் என்று நான் இந்த பிரச்சினையை கொண்டு இயங்கும், Google புரிந்து தெரிகிறது ஒருபோதும், அதனால் நான் இந்த எழுதி என்று உருவம்.

நான் கடந்த வாரம் அல்லது இரண்டு நிகழ்வு ரிசீவர் பிழைதிருத்தம் நிறைய செய்து. The ER is defined against a document library. The individual items in the document library are tightly related to their parent folders. அப்படி, I am always getting the folder of the item for various manipulations. While debugging, நான் யாருடைய அடையாள எனக்கு ஒரு குறிப்பிட்ட உருப்படியை ஒரு கோப்புறை மெட்டா மேம்படுத்த தேவை.

இங்கே ஒரு சிறிய பணியகம் விண்ணப்ப படிவம் (பண்ணை உள்ள சர்வர் இயக்க வடிவமைக்கப்பட்ட) இரண்டு வாதங்களை எடுத்து: ஒரு உருப்படி ஐடி மற்றும் ஒரு துறையில் ஒதுக்க மதிப்பு, "Approval Status". It hard codes a lot of stuff and has no error checking.

குறியீடு ஒரு வன் குறியீட்டு தளத்தில் வரை தெரிகிறது, 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.

யாராவது ஒரு விமர்சனத்தை வழங்க அல்லது ஒரு பொருளின் அடைவை பெற ஒரு சிறந்த வழி பரிந்துரைக்கும் அக்கறை இருந்தால்,, ஒரு விடுங்கள்.

<குறியீடு>
பயன்படுத்தி முறை;
பயன்படுத்தி System.Collections.Generic;
பயன்படுத்தி System.Text;
பயன்படுத்தி Microsoft.SharePoint;
பயன்படுத்தி System.Collections;

நேம்ஸ்பேஸ் Conchango
{
    /// <சுருக்கம்>
 /// </சுருக்கம்>
 வர்க்கம் ManualFolderUpdate
    {
        நிலையான களைவதற்கு முக்கிய(மாலை[] மதிப்புரு)
        {
            மாலை msh = "ManualFolderUpdate (v1.0): "; // msh = "Message Header"

 தேற்று.WriteLine(msh + "Starting up.  நான் கடந்த 08/04/08 மணிக்கு திருத்தினோம்.");

            மாலை URL = http://localhost/xyzzy;

            பயன்படுத்தி (SPSite oSPSite = புதிய SPSite(URL))
            {

                பயன்படுத்தி (SPWeb oSPWeb = oSPSite.OpenWeb())
                {
                    SPList docLib = oSPWeb.Lists["Documents"];

                    தேற்று.WriteLine(msh + "Got the document library.");

                    தேற்று.WriteLine(msh + "Doc lib item count: [" + docLib.ItemCount + "].");

                    எண்ணாக FolderID = 0;
                    மாலை NewStatus = "xyzzy";

                    FolderID = அமைப்பு.மாற்று.ToInt32(மதிப்புரு[0].ToString());
                    தேற்று.WriteLine("Seeking folder for item: [" + FolderID + "].");

                    SPListItem li = docLib.GetItemById(FolderID);

                    SPFolder thisItemFolder = li.File.ParentFolder;

                    தேற்று.WriteLine(msh + "Got the parent folder.");

                    NewStatus = ARGS[1].ToString();
                    தேற்று.WriteLine("Setting status to [" + NewStatus + "].");

                    தேற்று.WriteLine("Press return to commit the update or CTRL-C to abort.");

                    தேற்று.ReadLine();

                    thisItemFolder.Item["Approval Status"] = NewStatus;
                    thisItemFolder.Item.Update();

                    தேற்று.WriteLine(msh + "Finished updating the folder.  வெளியேறும்.");

                } // SPWeb பயன்படுத்தி

            } // SPSite பயன்படுத்தி

 தேற்று.WriteLine(msh + "Finished.");

        } // முக்கிய

    } // வர்க்கம் foldersync
} // நேம்ஸ்பேஸ்
</குறியீடு>

</இறுதியில்>

என்னுடைய குழுசேர்.

Technorati குறிச்சொற்கள்:

ஒரு பதில் விட்டு

உங்கள் மின்னஞ்சல் முகவரி வெளியிடப்பட்ட முடியாது. தேவையான புலங்கள் குறிக்கப்பட்டன *