Skip to main content

Posts

Showing posts from April, 2017

How to upload file to FTP server using C# Asp.Net #RathrolaPremKumar

This post is about uploading files to FTP server in asp.net development. You will learn step-by-step to upload files programmatically to FTP web server. All the examples shared in this post are intended by professionals to make you learn about the subject
Here, I will explain you an example of Uploading Files to FTP Server programmatically in C#.Net. Using this approach, the Files will be pro grammatically uploaded to FTP Web Server. For example, I will create a function in which we will simply provide the local file name to upload, upload path of FTP (including host name, FTP username and FTP password). This function uses System.Net and System.IO namespaces to upload the file.
Let’s create a simple console Application to give you example of Uploading Files to FTP Server. So, a new console application will be something like this,

Now, add references of the System.Configuration Assembly to the project in the following way. 1.Right click on the project and click Add Reference option from the…

How to Export SharePointList to Excel Using C# Programatically 2017 #RathrolaPremKumar

Hi All,
 Today I will give you the code for exporting data from SharePoint List to Excel.

Ok Without delay, directly going to the code...



SOURCE CODE:



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using System.Data;
using System.IO;
using System.Web.UI;

namespace Excel
{
    class Program
    {
        private static DataTable dataTable;
        private static SPList list;

        static void Main(string[] args)
        {
            try
            {
                SPSite Osite = new SPSite("http://PremKT/sites/Testing/Creative%20CR%20Tracker");
                SPWeb oWeb = Osite.OpenWeb();
                string _siteUrl = oWeb.Url.ToString();
                if (!string.IsNullOrEmpty(_siteUrl))
                {
                    SPSecurity.RunWithElevatedPrivileges(delegate()
                    {
                        using (SPSite site = new SPSite(oWeb.Url))
                        {
             …

The list is too large to save as a template. The size of a template cannot exceed 10485760 bytes in SharePoint

In SharePoint 2013: By default it is 50MB in SharePoint 2010 or SharePoint 2013. So if it increased the limit then it will give an error like below,


ou can also use PowerShell command to increase the limit like below:
Add-PSSnapinMicrosoft.SharePoint.Powershell $webservice=[Microsoft.SharePoint.Administration.SPWebService]::ContentService Write-Host"Size: "$webservice.MaxTemplateDocumentSize $webservice.MaxTemplateDocumentSize =262144000#250 MB $webservice.Update() 
Hope this will be helpful.

SharePoint Config Increasing the maximum size of list templates #RathrolaPremKumar

Saving a list as a template is an easy way of transferring data from one place to another in SharePoint. By default, however, the maximum size of list templates in WSS 3.0 and MOSS 2007 is 10MB.

If you try to save the list as a template that is larger than this you will get the following error:

The list is too large to save as a template. The size of a template cannot exceed 10485760 bytes.

To increase the maximum size, simply run the following stsadm command (from the C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN directory) replacing the propertyvalue to the new maximum size (in bytes):


stsadm -o setproperty -propertyname max-template-document-size -propertyvalue 50000000

Points to note:

The propertyvalue parameter is in bytes, so the example above will increase the maximum size to approx 50MB.
There is a hard limit of 500MB so the value must be less than 524288000 or you will get an error when saving the list as a template.
The above increases the maxim…

'#Resolve' To export a list, you must have a Microsoft SharePoint Foundation-compatible application.

Searching this error message easily finds the root of the problem. There is a problem with the Office 64 bit version. It doesn’t work with SharePoint. These solutions generally tell you to uninstall your 64 bit office and install a 32 bit version. Happily there is a much easier solution.
Despite the error message the export actually works! Notice the yellow bar at the bottom of your browser. Simply save the .iqy file normally and open it with Excel. It’s that simple. The error message is certainly a nuisance but does not actually stop the export.
Thanks for ready my blog :)

Resolve Class not registered exception - SharePoint 2013 By #RathrolaPremKumar

Hi All,

We got below error when trying to use SPSecurity.RunWithElevatedPrivileges in console application



Retrieving the COM class factory for component with CLSID {BDEADF26-C265-11D0-BCED-00A0C90AB50F} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).

SourceCode:
using Microsoft.SharePoint;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SampleComnsoleApp
{
    class Program
    {

        static void Main(string[] args)
        {
            bool quiet = false;
            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                (new Program()).Run(quiet);
            });
        }
        private void Run(bool quiet)
        {

        }
    }

}

Resolution: 
The console application is running under 32 bit processor. Just change it to 64 bit.
To do this:

Right click on Console Application
Select Properties 
Under Build Tab, change Platform Targ…