I am trying to copy a selected from from a SharePoint Document List to the servers local drive. But I can not for the life of me find a way to do this within SharePoint 2010 using C# or JavaScript (preferably C#) anywhere. Is this possible? If it is, can anyone provide some pointers that would get me started in the right direction? Thanks!
You can use custom actions to integrate the functionnality to ribbon (see this article).
Once you have added your custom action in the code you can:
If you know a file server relative URL you can get it from the web
SPFile file = YourWebObject.GetFile("FileServerRelativeUrl");
Ones you have your SPFile object you can save it, using .NET IO library, to a disk using
FileStream fileStreamToSave = YourWebObject.OpenBinaryStream();
Than just save it...
IMPORTANT! - You have to give writ access to the folder where you files will be stored.
Related
My first question on stackoverflow, I hope I am following the rules.
Anyhow, as the title suggests, I need to figure out how to programmatically add pages to a wiki library. I set up upwards of 30,000 rows in Excel, VBA'd them into txt files containing html that portray articles, and now they are sitting in a folder with nowhere to go. They need to go into a wiki library on SharePoint, where they will be referenced by users in their articles. Two parts:
On single-file upload, cannot upload aspx files. I upload as txt or html and it goes fine. Then I try to change them to aspx. Illegal.
Cannot upload more than one file at a time. Once I figure out #1, this will be an issue.
I assumed there must be a way to mimic whatever the "wikification" process is for files programmatically. Microsoft's how-to on file uploading requires a Sharepoint Project, which requires VS Professional and running SharePoint locally. Neither of these is practical.
Thank you and godspeed.
You could write a small Powershell Script or Commandline application for example in C# or VB. Copy your files to the server and execute your script/app on the SharePoint server. Connect to your SharePoint like the following:
using Microsoft.SharePoint;
...
SPSite site = new SPSite("mysiteurl");
SPWeb web = site.OpenWeb();
// your code goes here
web.dispose();
site.dispose();
...
Then get the directory programmatically where your files reside.
If this was successful, loop through all files in your folder and upload them programmatically to the WIKI Library.
Sound complex, but if you search for the single topics, you will find a lot of solutions/code out there.
You could also write a Console Application which can connect remotely to the SharePoint Server without the need to be executed on the SharePoint itself. In this case you would need to use the Client Object Model (CSOM).
The Office 365 Patterns and Practices site is a great reference. It has a comprehensive sample for creating wiki pages using CSOM here
I was trying to find any tool that I can use to create ONET file from the existing SharePoint site. Unfortunately wasn't able to find. Does anybody know anything about that? There should be something besides of manual way to do that... Any MS solutions, third party tools?
As John Saunders is alluding, the simplest approach would be to let SharePoint create it for you. It's not exactly sitting in the site though; you can't just open the site in SharePoint Designer & grab it - but there is a way to get it:
Save the site as a Site Template (with or without content, doesn't matter - but without will be faster/smaller)
Download the STP/WSP from the Site Template (SP2007)/Solutions (SP2010/13) Gallery to your desktop
Change the file extension to .CAB
Use an archive tool (i.e. 7-zip) to unpack the CAB file
Within the unpacked CAB you will see a folder whose name will be the original name of your Site Template + "WebTemplate"
Within that folder will be a sub-folder whose name is just the original name of your Site Template
Within that folder is the ONet.xml file
I have a silverlight application inserted in a SharePoint page. The SilverLight application runs on a different server thatn that of SharePoint. From an event in the SilverLight, I generate a document on the server side from SQL Server. I can generate the doc on the server hosting the silverlight application and also copy it to the SharePoint server. I wanted to know if I can include this file in a sharepoint document library automatically. I was thinking if like emailing to a list allows us to copy the file into the library, can we configure the reverse, means copying the file make it part of the list.
Update:
I wanted to avoid uploading. For me uploading is sending the file from one location to the target location. But what I am saying is, if I copy the file into the folder where SharePoint keeps the file physically for the particular list, can it be added to the list automatically?
I am not sure, how well I am being able to describe the point. Please elaborate if required or I can answer your queries.
SharePoint stores the files in a database, not a folder.
WebDAV access may be what you're looking for - it's a backbone of the the Explorer View feature that allows a user to access a document library as if you were accessing a file system through a Windows Explorer window.
You can configure "incoming e-mail" properties for the document library, and assign an e-mail address.
After that, when you e-mail a document as attached to e-mail to this e-mail address, then attachment will be saved to that library by sharepoint automatically.
I’m trying to write a macro to connect to an https sharepoint directory and read the list of files contained within the directory (so that I can parse the filenames and then open the appropriate one and read some data from it).
So far I’ve tried:
Get the content of a sharepoint folder with Excel VBA. Set folder = fs.GetFolder seems to
work with an http sharepoint, but not
an https: sharepoint
http://blog.itwarlocks.com/2009/04/28/accessing-webdav-in-microsoft-word-visual-basic/
getChildren() doesn’t work here. The directory is returned as a simple
record (even though it's actually a complex one with a subfolder and files, that should have Children).
connecting to an excel document on the sharepoint and then invoking the shared workspace function. This doesn't return any documents in the directory even though there are several other files in the directory.
Has anyone had success with this on a secure https sharepoint directory??
Sharepoint exposes webservices. You can use these to iterate through your libraries.
http://msdn.microsoft.com/en-us/library/ms479390(v=office.12).aspx
Sharepoint 2010 also provides the managed Client Object Model.
This will do what you want:
http://msdn.microsoft.com/en-us/library/aa159897(v=office.11).aspx
If the files you want are in a document library, you could use WebDAV to get access to them via something like:
\sp.example.com\sites\thesite\doclib\foldername
OK I am new to working with SHarePoint Services and have an issue that I am trying to overcome. Where I work, I have implemented a Crystal reports Scheduler that outputs the reports to a shared folder. What I am trying to accomplish now is finding a way that I can point the output of the scheduler to the document library. I was hoping that I could find it like any other shared folder.
On your box hosting sharepoint, turn on the WebClient Service.
Goto the library you wish to upload to, drop down on actions-> open in windows explorer
The path you see can be converted to a UNC path, where you can use it like any other shared folder.
To convert, it should look like \\servername\Shared Documents
This unc can be mapped as a shared folder like any other physical networked folders.
Happy Uploading!
If you want to upload the file in your code (not manually) without mounting a WebDAV share, you can also HTTP-PUT it to the desired URL, for example http://myserver/sites/mysite/mysubsite/mylist/myfolder/foo.doc
Try the code in this question: Uploading files to Sharepoint (WSS 3.0) document library using HTTP PUT
With the tip in this answer: Uploading files to Sharepoint (WSS 3.0) document library using HTTP PUT.