Sunday, October 30, 2011

SPAttachmentCollection Reading attachments from a list item


SPSite oSiteCollection = SPContext.Current.Site;
SPWebCollection collWebsites = oSiteCollection.AllWebs;

SPWeb oWebsite = collWebsites["Site_Name"];
SPFolder oFolder = oWebsite.Folders["Shared Documents"];

foreach (SPWeb oWebsiteNext in collWebsites)
{
    SPList oList = oWebsiteNext.Lists["List_Name"];
    SPListItemCollection collItem = oList.Items;
    SPListItem oListItem = collItem[0];
    SPAttachmentCollection collAttachments = oListItem.Attachments;

    SPFileCollection collFiles = oFolder.Files;

    foreach (SPFile oFile in collFiles)
    {
        string strFileName = oFile.Name;

        byte[] binFile = oFile.OpenBinary();

        collFiles.Add(strFileName, binFile);
    }

    oListItem.Update();
    oWebsiteNext.Dispose();
}
oWebsite.Dispose();

Thursday, October 20, 2011

Adding Project Items(available project items for local and Web projects)



Adding Project Items

The following tables list the available project items for local and Web projects. Note that for some project items, the file extension differs depending on whether the item occurs in a Visual Basic project (indicated by .vb) or in a Visual C# project (indicated by .cs). For other project items, the file extension does not distinguish between a Visual Basic project and a Visual C# project; that is, there is only one possible file extension for the project item.
Local Project Items
Project Item
File Extension
Purpose of the Project Item
Windows Form
.vb or .cs
A form for creating Windows applications. For more information, see Creating Windows Forms.
Class
.vb or .cs
A code file that contains a class declaration. For more information, see Classes.
Module (Visual Basic only)
.vb
A file for storing groups of functions.
Component Class
.vb or .cs
A class for creating components using the visual designer. For more information, see Component Classes.
User Control
.vb or .cs
A class for creating a Windows Form control using the visual designer.
Data Form Wizard
.vb or .cs (.aspx for Web projects.)
A data form for Windows applications. For more information, see Data Form Wizard.
DataSet
.xsd
A file for creating an XML schema with DataSet classes. For more information, see Visual Studio Tools for Creating Datasets.
XML File
.xml
A blank XML file. For more information, see XML Designer.
XML Schema
.xsd
A file for creating a schema for XML documents. For more information, see Introduction to XML Schemas.
Code File
.vb or .cs
A blank code file.
Custom Control
.vb or .cs
A class for creating a user-drawn Windows Form control. For more information, see Authoring Controls for Windows Forms.
HTML Page
.htm
An HTML page that can include client-side code. For more information, see Design View, HTML Designer.
Inherited Form
.vb or .cs
A new form based on an existing Windows Form. For more information, see Windows Forms Inheritance.
Web Custom Control
.vb or .cs
A class for creating an ASP.NET server control. For more information, see ASP.NET Server Controls.
Inherited User Control
.vb or .cs
A new control based on an existing Windows Form control. For more information, see Inheriting from Existing Windows Forms Controls.
Windows Service
.vb or .cs
A class for creating Windows services. For more information, see Creating Windows Services.
COM Class
.vb or .cs
A class that can be exposed to COM. For more information, see COM Interoperability in Visual Basic and Visual C#.
Transactional Component
.vb or .cs
A class for use with transactional components.
Text File
.txt
An empty text file.
Frameset
.htm
An HTML file that hosts multiple HTML pages. For more information, see Introduction to Framesets.
XSLT File
.xslt
A file used to transform XML documents. For more information, see XSLT Developer's Guide.
StyleSheet
.css
A cascading style sheet used for rich HTML style definitions. For more information, see Creating an External CSS Style Sheet.
Installer Class
.vb or .cs
A class to be invoked at setup time. For more information, see Creating Installation Components.
Crystal Report
.rpt
A Crystal Report file that publishes data to a Windows form. For more information, see Crystal Report Designer Overview.
Bitmap File
.bmp
A blank bitmap image file that can be used for creating simple images.
Cursor File
.cur
A file for creating custom cursors. For more information, see Cursor Creation.
Icon File
.ico
An image file for creating a custom icon. For more information, see Icons.
Assembly Resource File
.resx
A file used to edit and define application resources. For more information, see Resources in Applications.
Assembly Information File
.vb or .cs
A file containing general assembly information. For more information, see Assemblies.
Application Configuration File
.config
A file used to configure application settings. For more information, see Configuration Files.
JScript File
.js
A script file containing JScript code. For more information, see JScript Fundamentals.
VBScript File
.vbs
A script file containing VBScript code. For more information, see VBScript User's Guide.
Windows Script Host
.wsf
A file containing script that is run as a Windows program. For more information, see Using Windows Script Files.
Web Project Items
Project Item
File Extension
Purpose of the Project Item
Web Form
Two files: .aspx and either .vb for Visual Basic or .cs for Visual C#
A form for creating Web applications. For more information, see Web Forms Pages.
Web Service
Two files: .asmx and either .vb for Visual Basic or .cs for Visual C#
A component that provides the ability to exchange interoperable messages using standard protocols such as HTTP, XML, XSD, SOAP and WSDL. For more information, see Creating XML Web Services in Managed Code.
Mobile Web Form
.aspx
A form for creating mobile Web applications. For more information, see Creating ASP.NET Mobile Web Applications.
Class
.vb or .cs
A code file that contains a class declaration.
Module (Visual Basic only)
.vb
A file for storing groups of functions.
Component Class
.vb or .cs
A class for creating components using the visual designer.
Data Form Wizard
.aspx (.vb or .cs for local projects)
A data form for Web applications. For more information, see Data Form Wizard.
DataSet
.xsd
A file for creating an XML schema with DataSet classes. For more information, see Visual Studio Tools for Creating Datasets.
Web User Control
.ascx
An ASP.NET server control created using the visual designer. For more information, see Developing ASP.NET Server Controls.
Mobile Web User Control
.ascx
An ASP.NET server control created using the visual designer and used in a mobile Web application. For more information, seeCreating ASP.NET Mobile Web Applications.
HTML Page
.htm
An HTML page that can include client-side code. For more information, see Design View, HTML Designer.
Frameset
.htm
An HTML file that hosts multiple HTML pages. For more information, see Introduction to Framesets.
Style Sheet
.css
A cascading style sheet used for rich HTML style definitions. For more information, see Creating an External CSS Style Sheet.
XML File
.xml
A blank XML file. For more information, see XML Designer.
XML Schema
.xsd
A file for creating a schema for XML documents. For more information, see Introduction to XML Schemas.
XSLT File
.xslt
A file used to transform XML documents. For more information, see XSLT Developer's Guide.
Web Custom Control
.vb or .cs
A class for creating an ASP.NET server control. For more information, see ASP.NET Server Controls.
Code File
.vb or .cs
A blank code file.
Static Discovery File
.disco
An optional file that acts as a discovery mechanism for the XML Web service. The .disco file is not automatically created for an XML Web service. For information on creating a discovery file for your XML Web service, see Enabling Discovery for an XML Web Service.
Global Application Class
.asax
Sometimes called an asax file, this file allows you to write code to handle global ASP.NET application-level events such asSession_OnStart and Application_OnStart. The file has a name of global.asax, which you cannot change. For more information, see The Global.asax File.
Web Configuration File
.config
ASP.NET uses this file to configure the Web settings for a Web project. The file has a name of Web.config, which you cannot change. For more information, see Application Root Directory Configuration File (Web.config).
Text File
.txt
An empty text file.
Installer Class
.vb or .cs
A class to be invoked at setup time. For more information, see Creating Installation Components.
Crystal Report
.rpt
A Crystal Report file that publishes data to a Web Form. For more information, see Crystal Report Designer Overview.
Bitmap File
.bmp
A blank bitmap image file that can be used for creating simple images.
Cursor File
.cur
A file for creating custom cursors. For more information, see Cursor Creation.
Icon File
.ico
An image file for creating a custom icon. For more information, see Icons.
Assembly Resource File
.resx
A file used to edit and define application resources. For more information, see Resources in Applications.
Assembly Information File
.vb or .cs
A file containing general assembly information. For more information, see Assemblies.
JScript File
.js
A script file containing JScript code. For more information, see JScript Fundamentals.
VBScript File
.vbs
A script file containing VBScript code. For more information, see VBScript User's Guide.
Windows Script Host
.wsf
An empty code file used for Windows scripting. For more information, see Introduction to Windows Service Applications.

Featured Posts

#Linux Commands Unveiled: #date, #uname, #hostname, #hostid, #arch, #nproc

 #Linux Commands Unveiled: #date, #uname, #hostname, #hostid, #arch, #nproc Linux is an open-source operating system that is loved by millio...