Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SharePoint > SharePoint Development
|
SharePoint Development Programming and development for SharePoint Portal Server and Windows SharePoint Services
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SharePoint Development section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 31st, 2009, 09:02 AM
Registered User
 
Join Date: Mar 2009
Posts: 9
Thanks: 1
Thanked 0 Times in 0 Posts
Default Was trying to create Folder programatically in a Doc Library

HI All

I was trying to create Document librray programatically in a Sharepoint Site and is not working for me.I was trying to implement this as an Event Handler.
The aim of the code is to create a Folder with the same name as in folder which has been added.For eg if i am creating a folder titled A in a Doc library called A1 then I shud have a folder names A(programatically) in a document library called as 'Request for Proposals' (this is predifened)
below is the piece of code.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;

namespace folderprog
{
public class folder:SPItemEventReceiver
{
SPSite site;
SPWeb web;

public override void ItemAdded(SPItemEventProperties properties)


{
//base.ItemAdding(properties);



site = new SPSite("http://a2ms04866:6000/presales");
web = site.OpenWeb();
SPListItem mainitem = properties.ListItem;
string fname=Convert.ToString (mainitem ["Name"]);




SPList list = web.Lists["Request For Proposal"];
if (list.EnableFolderCreation != true)
{
list.EnableFolderCreation = true;
list.Update();
}
string url = "http://a2ms04866:6000/presales/Request%20For%20Proposal";

list.Folders.Add(url , SPFileSystemObjectType.Folder, fname);

list.Update();




}
}
}


can somebody help me on this ??

Jags





Similar Threads
Thread Thread Starter Forum Replies Last Post
Create a thumbnail image of a Word doc SQLScott Pro Visual Basic 2005 4 February 6th, 2013 08:54 AM
Class library folder path arunkhushi C# 1 February 4th, 2008 12:59 PM
Create XML Doc with Stylesheet Declaration rodmcleay General .NET 1 November 15th, 2004 04:11 AM
How do you create anchors programatically? ggreen001 Classic ASP Components 1 August 28th, 2003 08:35 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.