Archive for July 13th, 2012

‘Microsoft.SharePoint.Client.Form’ does not contain a constructor that takes 0 arguments – SharePoint 2010 Client Object Model

To fix this issue, just click here. Thanks, R../

, , , ,

1 Comment

How to get the list of folders and subfolders from a SharePoint document library

There are many ways to get files & folder details from SharePoint (programmatically) but my manager asked me to provide the list of folders and sub folders from a SharePoint document library urgently. So I wanted get an idea to provide the information quickly, after spending few minutes on the web and found this post (I know about the DIR command but didn’t think about the SharePoint UNC). Yes, we can get the details using DOS command with UNC path. 🙂

First of all, we want to know about UNC and the DIR command.

UNC: Universal Naming Convention, a format for specifying the location of resources on a local-area network (LAN). Read more about this here.

Syntax: \\<servername>\<sharename>\<directory>

DIR: Display a list of files and subfolders. Read more about this here.

Syntax: DIR [pathname(s)] [display_format] [file_attributes] [sorted] [time] [options]

To get SharePoint UNC path, just remove http: from the SharePoint url and replace the forward slash with backslash. So my document library path is:

http://ServerName/doccenter/Administration/StepBiStep

then it’s UNC will be like this:

\\ServerName\doccenter\Administration\StepBiStep

Okay.. we will see the steps here, I have created a document library (StepBiStep) for testing purpose.

Step 1: Open the cmd prompt

Step 2: type the following statement in the command-line and press Enter key.

DIR /B /A:D / S [UNC Path] > [File Name]

/B -Bare format (no heading, file sizes or summary)
/A:D -Folder file attributes
/S -Include all subfolders
[UNC Path] -The path, which you want to get all the folders and subfolders
[File Name] -A text file name to store the folder details

So our command is looks like this, I have used a text file (FolderLists.txt, which is located in C: drive) to store the details.

DIR /b /A:D /S \\ServerName\doccenter\Administration\StepBiStep > c:\FolderLists.txt

Step 3: It will take few minutes to generate the list. You can open in a Notepad and see..!.

That’s all guys, enjoy!  I do welcome your comments. Please leave them here! 🙂

References:

1. http://ss64.com/nt/dir.html

2. http://www.sharepointgeoff.com/how-to-quickly-list-documents-and-sub-folders-from-a-document-library-in-sharepoint-to-a-file/

3. http://technet.microsoft.com/en-us/library/cc939978.aspx

Advertisement

, , , , , , ,

Leave a comment

‘Form’ is an ambiguous reference between ‘System.Windows.Forms.Form’ and ‘Microsoft.SharePoint.Client.Form’ – SharePoint 2010 Client Object Model

When you try to use the Client Object Model (SharePoint 2010) with Windows Application in Visual Studio 2010, you might be getting these error messages. (You can find the step by step instructions to use the SharePoint 2010 Client Object Model here)

Error Message:

'Form' is an ambiguous reference between 'System.Windows.Forms.Form' and 'Microsoft.SharePoint.Client.Form'

Reason: The reason is obvious and we can get from the error message itself. Yes, after added the  SharePoint Client reference to the code, there is a conflict between ‘System.Windows.Forms.Form’ and ‘Microsoft.SharePoint.Client.Form’! Initially our Form1 class inherits from Form class (by default System.Windows.Forms.Form) and currently our program confuses to choose the correct reference.

Solution: Provide full reference to the Form class will be the solution for this issue, so replace ‘Form‘ with ‘System.Windows.Forms.Form
After Replacing the code:

public partial class Form1 : System.Windows.Forms.Form
 {
 public Form1()
 {
 InitializeComponent();
 }
}

That’s all guys, Happy Programming with Client Object Model.

Thanks, R../

2 Comments

The type or namespace name ‘SharePoint’ does not exist in the namespace ‘Microsoft’ (are you missing an assembly reference?) – SharePoint 2010 Client Object Model dlls

When I started using the Client Object model (Client OM) in SharePoint 2010, I have got this simple error and I just want to share with you in this blog. Following was my develpment environment.

  • Windows 7, 64 bit
  • Console Application Visual Studio 2010
  • Added Client Object Model references (Microsoft.SharePoint.Client.dll & Microsoft.SharePoint.Client.Runtime.dll) to the solution

After setting up all the above, I was trying to add the client reference to the code ‘using Microsoft.SharePoint.Client;‘and then I have got the following error and warnings 🙂

The text format of error is:

"The type or namespace name 'SharePoint' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)"

It’s an obvious error message and the reason of this error is:

SharePoint 2010 does not support .Net 4.0 in default and Visual Studio 2010 default framework is .Net 4.0.

Here are the simple steps to fix this:

Step 1: Right click on the project –> Properties

Step 2: Change the Target framework –> .Net Framework 3.5

Step 3: Warning message will be popping up, click Yes.

That’s all. Happy Coding..!

Please Note: If you use Windows Application then you will be getting an other error message! 😦 To solve this issue just click here.

, , , , , , , , , ,

1 Comment