473,765 Members | 2,001 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

3 New Member
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 5543
tlhintoq
3,525 Recognized Expert Specialist
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.Direc tory
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
1857
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 uses it. thx
1
1731
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
2634
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 results displayed on the same page with one column text and an image of the product. I've seen several tutorials that create site-level searches that will bring back a search results page with options to choose from. I am looking to create a...
0
2281
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 recommended and b) if there is another way. I want to add the projects under the sharepoint site as I want authentication but do not want my users to have to login everytime they access a net app from within the sharepoint site. Ideally, they...
2
4100
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. Integrated Windows Auth is ON for this portal. There are a few word documents in the site and i can acess then off url - http://sitename/site/<DocumentLibrary>/intro.doc I have to write a web app which uses Interop.Word.dll for
3
1382
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 is http://localhost/myproject/, differing from the local server root http://localhost/. This means a lot of trouble since some url rewriting on my site forces me to use absolute referers such as "/file.jpg" in a href and img src attributes, which...
2
4335
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 server. From what I understand I need to exclude in sharepoint services the folder where the application will be deployed. I have done this in the Define Managed Paths section of the Sharepoint management site, but it has no effect. Even after...
2
1556
by: deepaks85 | last post by:
Dear Friends, How can I create site map for any website in php? Please advice........ Thanks Deepak
0
1148
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 required data to be selected, e.g. logo, job description, start date etc... When the job scrape is run the data is scraped to a database. the example tool is imacro from http://www.iopus.com and web content extractor from...
0
9568
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10160
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9951
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9832
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7378
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5275
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5421
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3531
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2805
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.