Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8584007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:40:08+00:00 2026-06-11T21:40:08+00:00

I have this event receiver c# class that I am trying to implement on

  • 0

I have this event receiver c# class that I am trying to implement on a Sharepoint site. It did not work. I have deployed it from visual studio 2010 after it was build ok. Does anyone see what is the problem? Is the code ok? or is the problem on the SP? Thank you.
– here is the new code

    using System;
using System.Security.Permissions;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Security;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.Workflow;

namespace EventReceiverCFolder.EventReceiver1
{
    /// <summary>
    /// List Item Events
    /// </summary>
    public class EventReceiver1 : SPItemEventReceiver
    {
        /// <summary>
        /// An item is being added.
        /// </summary>
        public override void ItemAdded(SPItemEventProperties properties)
        {

            try
            {
                if (properties.ListTitle == "CF") // list where the item was added 
                { // if item was added to this list then create a folder on -  Dlib - list
                    UpdateFolder(properties);
                }
            }
            catch (Exception ex)
            {
                properties.Status = SPEventReceiverStatus.CancelWithError;
                properties.ErrorMessage = ex.Message;
                properties.Cancel = true;
            }
        }

        private void UpdateFolder(SPItemEventProperties properties)
        {
            string foldername = properties.ListItem["Title"].ToString();

            try
            {
                SPSecurity.RunWithElevatedPrivileges(delegate()
                {
                    //inside RunWithElevatedPriviliges I need to open a new site (an elevated site) 
                    using (SPSite site = new SPSite(properties.Web.Site.ID))
                    {
                        using (SPWeb web = site.OpenWeb())
                        {
                            web.AllowUnsafeUpdates = true;
                            SPList list = web.Lists.TryGetList("DLib"); // this is doc Library where the new folder will be created
                            //note that we are creating a list item, not a folder - a folder IS a list item 
                            SPListItem createdFolder = list.Items.Add(list.RootFolder.ServerRelativeUrl, SPFileSystemObjectType.Folder, null);
                            if (createdFolder != null)
                            {
                            createdFolder["Name"] = foldername;
                                createdFolder.Update();
                            }
                            list.Update();
                        }
                    }
                });
            }
            finally { }
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T21:40:09+00:00Added an answer on June 11, 2026 at 9:40 pm

    I had to get folder name like this:

    string foldername = Convert.ToString(properties.AfterProperties["Title"]);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code : class Event{}; class CustomEvent:public Event{}; class Handler { public:
I have this event listener: input_1.addEventListener('input',function(){ updateFromInput(1); },false); It controls the location of a
I have this canvas mousedown event: $('#canvas').mousedown(function(e) { var coords = canvas.getMousePos(e); // user
I have this: function change( event, file ) { console.log( filename, file ); //It
I'm building a music events website and want to have a 'share this event'
I have this form submit code: Event.observe(window, 'load', init, false); function init() { Event.observe('addressForm',
I have this code for an event handler: rbM.setOnCheckedChangeListener(new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton
I have this in my JavaScript var identifier = event.target.id; it works on Chrome
I have a string like this: event name|event description|event type|event date|event time|event details, event
I have this code which is called at an onChange event of an function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.