473,320 Members | 1,724 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Was trying to create Folder programatically in a Doc Library(SharePoint Site)

3
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 in a document library called as 'Request for Proposals' (this is predifened)
below is the piece of code.


Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Microsoft.SharePoint;
  6.  
  7. namespace folderprog
  8. {
  9.     public class folder:SPItemEventReceiver 
  10.     {
  11.        SPSite site;
  12.        SPWeb web;
  13.  
  14.         public override void  ItemAdded(SPItemEventProperties properties)
  15.         {
  16.             //base.ItemAdding(properties);
  17.             site = new SPSite("http://a2ms04866:6000/presales");
  18.             web = site.OpenWeb();
  19.             SPListItem mainitem = properties.ListItem;
  20.             string fname=Convert.ToString (mainitem ["Name"]);
  21.             SPList list = web.Lists["Request For Proposal"];
  22.             if (list.EnableFolderCreation != true)
  23.             {
  24.                 list.EnableFolderCreation = true;
  25.                 list.Update();
  26.             }
  27.             string url = "http://a2ms04866:6000/presales/Request%20For%20Proposal";
  28.  
  29.              list.Folders.Add(url , SPFileSystemObjectType.Folder, fname);
  30.  
  31.             list.Update();
  32.         }
  33.     }
  34. }

can somebosy help me on this ??

Jags
Mar 31 '09 #1
1 5510
tlhintoq
3,525 Expert 2GB
TIP: When you are writing your question, there is a button on the tool bar that

wraps the [code] tags around your copy/pasted code. It helps a bunch. Its the button with a '#' on

it. More on tags. They're cool. Check'em out.

You want to read up on System.IO.Directory
Within that is a method for creating directories, as well as many other useful functions
Mar 31 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: deko | last post by:
How can I search for stuff on my site using php? Can someone point me to a php-based site search tool? I know Google has something, but you have to do free adverstising for them whenever anyone...
1
by: viviane lima - * - * - | last post by:
How create site with webmatrix with MySql ? it's possible ? thanks for help and links examples... Vivian vivianelima@ligbr.com.br
1
by: D. Lee Christopher | last post by:
Can anyone point me to a good tutorial for creating a site-level search applet? I am trying to create a virtual catalog of sorts, and I would like to be able to search the catalog and have the...
0
by: Ken Wigle | last post by:
All, I am trying to add some .net applications I wrote to a virtual directory underneath the sharepoint services web site. I am having some problems and wondering if a) this is possible and/or...
2
by: listname | last post by:
A SharePoint portal is running at http://sitename/. When I visit that web site, a dialog box comes up asking for network domain/userid/password. I provide the details and the site lets me in....
3
by: Erik ETS | last post by:
I need some symmetry between my development environment and my running web site. The root of my web site is http://www.mysite.com/ while the root of the project in my local development environment...
2
by: =?Utf-8?B?QWxhc3RhaXIgQmVsbA==?= | last post by:
I am having trouble creating a web site on a server running sharepoint services. I am creating an ASP.Net website using Visual Studio 2005. The server I am trying to create it on is a Windows 2003...
2
by: deepaks85 | last post by:
Dear Friends, How can I create site map for any website in php? Please advice........ Thanks Deepak
0
by: Hamayun Khan | last post by:
Hi I need to create site scrape tool(job scrap tool). Each site to be scraped needs to have a different job scrape configured as each site will be different. The job scrape tool will allow...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.