Jean Paul's Blog

There are 2 types of People in the World, One who Likes SharePoint and..

    Advertisements
  • Microsoft MVP

  • MindCracker MVP

  • CodeProject MVP

  • eBook on SharePoint 2010

  • eBook on Design Patterns

  • eBook on Windows Azure

  • NLayers Framework @ CodePlex

  • MSDN Forums

  • .Net vs. Java

    Due to Public Demand
  • Advertisements

Posts Tagged ‘library’

SharePoint 2010 > MS Word > New Document > Save Dialog > ‘Not Showing’ Document Library

Posted by Paul on September 26, 2013

Problems

For the past 2 years, I was seeing following problems reported by client.

  1. From SharePoint 2010 the user opened a document library & clicked on the ‘New Document’ toolbar item.  Microsoft Word was launched & while using the Save command, the original document library is not listed.  Instead a local folder being shown.
  2. From SharePoint 2010 the user opened a document in edit mode.  But while using the save command, it is prompting for save dialog, instead of saving automatically to SharePoint document library. 

Under the Hood

SharePoint rich client side features like open in Explorer, save directly to web server etc. are provided through WebDAV which represents Web Distributed Authoring and Versioning.  more

The client operating system should be running the WebClient service to enable this feature.

Solution

A typical set of solutions should be applied one-by-one to address the problem.  You can start with following.

  1. Internet Explorer Ensure you are using Internet Explorer 32-bit version.  If not start the appropriate version from start menu.
  2. Office Version Ensure you have a compatible MS Office version.  Office 2010 32 bit is best compatible with SharePoint 2010.
  3. Trusted Sites In the Internet Explorer Security Settings, ensure you have add the site url to trusted sites list.image 
  4. WebClient Open run window > services.msc & ensure WebClient service is running.  (If you are using server operating system as client, you need to install the Desktop Experience role to find WebClient service)
  5. Word Trust Center Open Microsoft Word > Options > Trust Center > Trust Center Settings.  Uncheck the 4 check boxes.image
  6. Install Patch Some client operating system requires a patch for the web folders to function properly.  You can download this from here.

Note

After each step, please restart the browser & test.

Advertisements

Posted in SharePoint, SharePoint 2010 | Tagged: , , , , , , , , , | Leave a Comment »

SharePoint 2010 – Create Document Library

Posted by Paul on June 4, 2012

In this article we can explore the creation of Document Library through code. Here we are using existing Document Templates inside SharePoint to create a new document library.

Following are the activities involved in Document Library creation:

· Find the List Template

· Find the Document Template

· Create Document Library

Inside Visual Studio

Create a new console application and name it as DocLibCreation. Make sure you change the target framework to .Net 3.5.

Add the following code into the Program.cs file:

using (SPSite site = new SPSite("http://appes-pc/my/personal/dotnet"))

{

using (SPWeb web = site.OpenWeb())

{

SPListTemplate listTemplate = web.ListTemplates["Document Library"];

SPDocTemplate docTemplate = (from SPDocTemplate dt in web.DocTemplates

where dt.Type == 122

select dt).FirstOrDefault();

Guid guid = web.Lists.Add("My Docs", "My Documents", listTemplate, docTemplate);

SPDocumentLibrary library = web.Lists[guid] as SPDocumentLibrary;

library.OnQuickLaunch = true;

library.Update();

}

}

Now run the application and you can see the new Document Library created inside SharePoint.

clip_image002


Document Templates

Following are the SharePoint 2010 document templates available:

Template ID

Description

100

No Template

101

Word 2003 document

103

Excel 2003 document

104

PowerPoint 2003 document

121

Word document

122

Excel document

123

PowerPoint document

111

OneNote Notebook

102

SharePoint Designer HTML document

105

ASPX Web Page

106

ASPX Web Part Page

1000

InfoPath document

Uploading Document

Now we can try uploading a document to the above library programmatically. Use the following code to upload an excel file. Make sure the application bin folder contains a file named sample.xlsx.

using (SPSite site = new SPSite("http://appes-pc/my/personal/dotnet"))

{

using (SPWeb web = site.OpenWeb())

{

SPDocumentLibrary library = web.Lists["My Docs"] as SPDocumentLibrary;

SPFile file = library.RootFolder.Files.Add("sample.xlsx", File.ReadAllBytes("sample.xlsx"));

}

}

You can see that the file is uploaded into SharePoint:

clip_image004

Downloading Document

Now we can try downloading a document from the above library programmatically. Use the following code:

using (SPSite site = new SPSite("http://appes-pc/my/personal/dotnet"))

{

using (SPWeb web = site.OpenWeb())

{

SPDocumentLibrary library = web.Lists["My Docs"] as SPDocumentLibrary;

SPFile file = web.GetFile(library.RootFolder.Url + "/sample.xlsx");

Stream stream = file.OpenBinaryStream();

FileStream fileStream = new FileStream("out.xlsx", FileMode.OpenOrCreate, FileAccess.Write);

int buffer = 4096;

int read = buffer;

byte[] bytes = new byte[buffer];

while (read == buffer)

{

read = stream.Read(bytes, 0, buffer);

fileStream.Write(bytes, 0, read);

if (read < buffer) break;

}

stream.Dispose();

fileStream.Dispose();

}

}

After running the program, you can see that the file is created in the bin folder.

clip_image006

This concludes the following activities:

1. Create Document Library

2. Upload a Document

3. Download a Document

References

http://www.learningsharepoint.com/2010/06/30/programatically-creating-document-sets-in-sharepoint-2010/

Summary

In this article we have the creation of document library through code. Please note that using the Document Type we can create different types of document library.

Posted in C#, SharePoint | Tagged: , , , | 6 Comments »

SharePoint 2010 – Create Document Library

Posted by Paul on June 4, 2012

In this article we can explore the creation of Document Library through code. Here we are using existing Document Templates inside SharePoint to create a new document library.

Following are the activities involved in Document Library creation:

· Find the List Template

· Find the Document Template

· Create Document Library

Inside Visual Studio

Create a new console application and name it as DocLibCreation. Make sure you change the target framework to .Net 3.5.

Add the following code into the Program.cs file:

using (SPSite site = new SPSite("http://appes-pc/my/personal/dotnet&quot;))

{

using (SPWeb web = site.OpenWeb())

{

SPListTemplate listTemplate = web.ListTemplates["Document Library"];

SPDocTemplate docTemplate = (from SPDocTemplate dt in web.DocTemplates

where dt.Type == 122

select dt).FirstOrDefault();

Guid guid = web.Lists.Add("My Docs", "My Documents", listTemplate, docTemplate);

SPDocumentLibrary library = web.Lists[guid] as SPDocumentLibrary;

library.OnQuickLaunch = true;

library.Update();

}

}

Now run the application and you can see the new Document Library created inside SharePoint.

clip_image002


Document Templates

Following are the SharePoint 2010 document templates available:

Template ID

Description

100

No Template

101

Word 2003 document

103

Excel 2003 document

104

PowerPoint 2003 document

121

Word document

122

Excel document

123

PowerPoint document

111

OneNote Notebook

102

SharePoint Designer HTML document

105

ASPX Web Page

106

ASPX Web Part Page

1000

InfoPath document

Uploading Document

Now we can try uploading a document to the above library programmatically. Use the following code to upload an excel file. Make sure the application bin folder contains a file named sample.xlsx.

using (SPSite site = new SPSite("http://appes-pc/my/personal/dotnet&quot;))

{

using (SPWeb web = site.OpenWeb())

{

SPDocumentLibrary library = web.Lists["My Docs"] as SPDocumentLibrary;

SPFile file = library.RootFolder.Files.Add("sample.xlsx", File.ReadAllBytes("sample.xlsx"));

}

}

You can see that the file is uploaded into SharePoint:

clip_image004

Downloading Document

Now we can try downloading a document from the above library programmatically. Use the following code:

using (SPSite site = new SPSite("http://appes-pc/my/personal/dotnet&quot;))

{

using (SPWeb web = site.OpenWeb())

{

SPDocumentLibrary library = web.Lists["My Docs"] as SPDocumentLibrary;

SPFile file = web.GetFile(library.RootFolder.Url + "/sample.xlsx");

Stream stream = file.OpenBinaryStream();

FileStream fileStream = new FileStream("out.xlsx", FileMode.OpenOrCreate, FileAccess.Write);

int buffer = 4096;

int read = buffer;

byte[] bytes = new byte[buffer];

while (read == buffer)

{

read = stream.Read(bytes, 0, buffer);

fileStream.Write(bytes, 0, read);

if (read < buffer) break;

}

stream.Dispose();

fileStream.Dispose();

}

}

After running the program, you can see that the file is created in the bin folder.

clip_image006

This concludes the following activities:

1. Create Document Library

2. Upload a Document

3. Download a Document

References

http://www.learningsharepoint.com/2010/06/30/programatically-creating-document-sets-in-sharepoint-2010/

Summary

In this article we have the creation of document library through code. Please note that using the Document Type we can create different types of document library.

Posted in C#, SharePoint | Tagged: , , , | 6 Comments »