A week ago i was just exploring Sharepoint 2010 Client Object model and have developed a utility which transfers all the documents from the windows folder to the Sharepoint document library.
Following are the steps to develop Offline Document uploader in SharePoint 2010 using Client Object Model.
1. Create a menu item which opens files uploader utility from windows folder’s context menu.
In order to create custom menu item in windows, we have to place an entry into registry.
I have first defined the two constant string variables as shown below that contains path to create a menu in the registry. You might have noticed that i have mentioned “Folder” at starting in both the values. This means that i want to create a context menu item at folder level. Otherwise if i place ” * ” it will be created at files, folder etc.
private const string MenuName = "Folder\\shell\\CMenuOption";
private const string Command= "Folder\\shell\\CMenuOption\Command";
Following is a code snippet that creates menu item at folder level. You can place it on any event. I have created two textboxes on a windows form i.e. txtMenuName and txtExecutablePath. In the txtMenuName textbox, i’ve specified menu item name and in the txtExecutablePath i’ve specified the .exe path of an application which transfers file to sharepoint library.
Here is the complete code which creates a menu item into the registry.
RegistryKey regmenu = null;
RegistryKey regcmd = null;
try
{
regmenu = Registry.ClassesRoot.CreateSubKey(MenuName);
if (regmenu != null)
regmenu.SetValue("", this.txtMenuName.Text);
regcmd = Registry.ClassesRoot.CreateSubKey(Command);
if (regcmd != null)
regcmd.SetValue("", this.txtExecutablePath.Text+ " \"%1\"");
}
catch (Exception ex)
{
MessageBox.Show(this, ex.ToString());
}
finally
{
if (regmenu != null)
regmenu.Close();
if (regcmd != null)
regcmd.Close();
}
Now there is a separate console application which sends the files from the folder path to the SharePoint document library. Following is the code snippet.
static void Main(string[] args)
{
String filepath = args[0].ToString();
Console.WriteLine(filepath);
Console.WriteLine("Processing Documents");
String[] files = Directory.GetFiles(filepath);
String docLibrary= System.Configuration.ConfigurationSettings.AppSettings.Get("DocLibrary").ToString();
String SPSiteURL= System.Configuration.ConfigurationSettings.AppSettings.Get("SPSiteURL").ToString();
ClientContext context = new ClientContext(SPSiteURL);
foreach (String fileName in files)
{
using(FileStream fileStream= new FileStream(fileName,FileMode.Open))
{
Console.WriteLine("Uploading file = " + fileName);
Microsoft.SharePoint.Client.File.SaveBinaryDirect(context, "/"+ docLibrary + "/" + Path.GetFileName(fileName), fileStream, true);
Console.WriteLine("Uploaded");
}
}
}
Finally, When the user clicks on “Upload files to SP” a console application runs and uploads all the documents in the Sharepoint document library.
Figure shows the Console Application uploading documents into SP doc library.
Figure shows the documents uploaded in the SP doc library.
Assalam-u-Alaekum,
Great work..
Nice blog….
Although it is very basic, good for the newly starter of the SharePoint
good work keep going….
Nice blog.
I want to know how can i further add companion metada for distinct documents using the same nature of utility.
Hi, i believe that i saw you visited my site thus i came to “go back the prefer”.I am trying to to find issues to improve my web site!I guess its adequate to make use of some of your ideas!!
I am glad to be a visitor of this gross site, appreciate it for this rare info!
I like this web blog very much, Its a really nice position to read and incur info .
I’ve recently started a web site, the info you offer on this web site has helped me tremendously. Thanks for all of your time & work.
I am extremely impressed together with your writing abilities and also with the structure in your weblog. Is that this a paid theme or did you customize it yourself? Anyway keep up the nice high quality writing, it’s rare to see a nice blog like this one today.
Excellent read, I just passed this onto a colleague who was doing some research on that. And he just bought me lunch since I found it for him smile So let me rephrase that: Thanks for lunch! “We strain to renew our capacity for wonder, to shock ourselves into astonishment once again.” by Shana Alexander.
I’ll right away grab your rss as I can not to find your email subscription hyperlink or e-newsletter service. Do you’ve any? Please permit me realize in order that I may just subscribe. Thanks.
I was reading some of your blog posts on this website and I believe this web site is real informative! Keep posting.
Please maintain on posting such quality storys as this is a rare thing to uncover these days. I am always looking online for posts that can assist me. watching forward to an additional excellent site. Great luck towards the author! all the greatest!
I like this web blog very much, Its a very nice post to read and incur information.
Keep up the fantastic piece of work, I read few blog posts on this web site and I think that your website is real interesting and holds bands of fantastic information.
I always was concerned in this subject and still am, regards for posting .
Very interesting topic, regards for putting up.
I haven’t checked in here for some time because I thought it was getting boring, but the last few posts are good quality so I guess I’ll add you back to my daily bloglist. You deserve it my friend 🙂
Rattling great information can be found on website.
You have noted very interesting details ! ps nice internet site . “Formal education will make you a living self-education will make you a fortune.” by Jim Rohn.
I think this website holds some rattling good info for everyone. “Philosophy triumphs easily over past evils and future evils but present evils triumph over it.” by La Rochefoucauld.
Thank you for sharing superb informations. Your web-site is so cool. I am impressed by the details that you have on this site. It reveals how nicely you understand this subject. Bookmarked this website page, will come back for more articles. You, my pal, ROCK! I found just the information I already searched all over the place and simply couldn’t come across. What a perfect web-site.
I like this blog very much so much good info.
Some really superb blog posts on this internet site , thankyou for contribution.
I visited a lot of website but I conceive this one has something special in it. “The better I get to know men, the more I find myself loving dogs.” by Charles De Gaulle.
I like this website very much so much superb information.
obviously like your web-site but you have to check the spelling on several of your posts. Several of them are rife with spelling problems and I in finding it very bothersome to tell the truth however I’ll surely come back again.
I like this post, enjoyed this one thanks for posting .
I am not really fantastic with English but I get hold this rattling easy to interpret.
Appreciate it for all your efforts that you have put in this. Very interesting info. “The deeper the sorrow the less tongue it hath.” by The Talmud.
Merely a smiling visitor here to share the love (:, btw great pattern .
Precisely what I was looking for, appreciate it for posting . “Pardon one offense, and you encourage the commission of many.” by Publilius Syrus.
I am so happy to read this. This is the kind of manual that needs to be given and not the accidental misinformation that’s at the other blogs. Appreciate your sharing this best doc.
But wanna say that this is handy , Thanks for taking your time to write this. “No kind of sensation is keener and more active than that of pain its impressions are unmistakable.” by Marquis de Sade.
I conceive you have remarked some very interesting details , appreciate it for the post.
Outstanding post, I conceive website owners should acquire a lot from this web site its very user genial. So much wonderful information on here :D.
hallo bros!! Super site!
Thanks for all your efforts that you have put in this. Very interesting info. “The words that enlighten the soul are more precious than jewels.” by Hazrat Inayat Khan.
Thanks a bunch for sharing this with all folks you really recognise what you are speaking approximately! Bookmarked. Kindly additionally consult with my web site =). We will have a link alternate agreement between us!
Very interesting topic , appreciate it for putting up. “The height of cleverness is to be able to conceal it.” by Francois de La Rochefoucauld.
Some genuinely fantastic content on this site, regards for contribution. “The spirit is the true self.” by Marcus Tullius Cicero.
But wanna remark on few general things, The website style and design is perfect, the subject matter is really wonderful : D.
Only a smiling visitor here to share the love (:, btw outstanding design .
Good web site! I really love how it is simple on my eyes and the data are well written. I’m wondering how I could be notified when a new post has been made. I have subscribed to your feed which must do the trick! Have a great day!
Appreciate it for helping out, wonderful info .
I am impressed with this internet site , really I am a fan .
There is apparently a bunch to realize about this. I believe you made some good points in features also.
This could be definitely one of the very most useful websites. We’ve arrive around on that subject. Definitely good. I’m also an specialist in this field so I can recognize your effort.
I was looking at some of your content on this website and I conceive this website is real instructive! Continue putting up.
Some genuinely quality articles on this site, saved to my bookmarks .
I’m very happy to read this. This is the type of manual that needs to be given and not the random misinformation that’s at the other blogs. Appreciate your sharing this greatest doc.
You have remarked very interesting details! ps decent website.
Very interesting topic, regards for putting up.
Thank you for the sensible critique. Me and my neighbor were just preparing to do a little research about this. We got a grab a book from our area library but I think I learned more from this post. I am very glad to see such fantastic information being shared freely out there.
I enjoy what you guys tend to be up too. This type of clever work and reporting! Keep up the good works guys I’ve added you guys to my personal blogroll.
Thanks for another magnificent post. Where else could anybody get that kind of information in such a perfect way of writing? I have a presentation next week, and I am on the look for such information.
Dead written written content, regards for information. “The bravest thing you can do when you are not brave is to profess courage and act accordingly.” by Corra Harris.
I got what you mean , thankyou for posting .Woh I am pleased to find this website through google. “The test and use of a man’s education is that he finds pleasure in the exercise of his mind.” by Carl Barzun.
>Excellent submit, Im trying to get as considerably info as feasible at the minute for my final undertaking to make sure I get the very best outcomes feasible, so preserve it coming
I like what you guys are up also. Such intelligent work and reporting! Carry on the excellent works guys I have incorporated you guys to my blogroll. I think it will improve the value of my site :).
I regard something genuinely interesting about your weblog so I bookmarked .
You have noted very interesting points! ps nice internet site.
Keep up the excellent piece of work, I read few posts on this website and I believe that your web site is really interesting and holds lots of excellent info .
Rattling nice pattern and good subject material, absolutely nothing else we want :D.
You are my breathing in, I possess few blogs and occasionally run out from to brand.
As soon as I detected this website I went on reddit to share some of the love with them. “So far as I can remember, there is not one word in the Gospels in praise of intelligence.” by Bertrand Russell.
Good ñ I should certainly pronounce, impressed with your website. I had no trouble navigating through all the tabs as well as related info ended up being truly easy to do to access. I recently found what I hoped for before you know it at all. Reasonably unusual. Is likely to appreciate it for those who add forums or anything, site theme . a tones way for your client to communicate. Excellent task.
These are really enormous ideas in concerning blogging. You have touched some pleasant things here. Any way keep up wrinting.
Great piece of info! May I reference part of this on my blog if I post a backlink to this webpage? Thank you.
I like this weblog very much, Its a very nice berth to read and obtain information.
I like this post, enjoyed this one appreciate it for putting up. “No trumpets sound when the important decisions of our life are made. Destiny is made known silently.” by Agnes de Mille.
Thanks for a marvelous posting! I truly enjoyed reading it, you might be a great author.I will be sure to bookmark your blog and will come back very soon. I want to encourage you to definitely continue your great job, have a nice weekend!
I like this site very much, Its a rattling nice situation to read and obtain info .
I am not very superb with English but I find this rattling easy to understand.
Hi there, just wanted to mention, I enjoyed this article. It was helpful. Keep on posting!
I really enjoy looking at on this web site , it contains wonderful blog posts.
Wow, marvelous weblog layout! How lengthy have you ever been blogging for? you made running a blog glance easy. The entire look of your site is fantastic, as smartly as the content!
Rattling nice style and excellent subject matter, nothing else we want :D.
hello there and thank you for your info – I’ve definitely picked up something new from right here. I did however expertise some technical points using this site, as I experienced to reload the web site many times previous to I could get it to load properly. I had been wondering if your hosting is OK? Not that I am complaining, but sluggish loading instances times will often affect your placement in google and could damage your high quality score if ads and marketing with Adwords. Anyway I’m adding this RSS to my e-mail and could look out for much more of your respective exciting content. Ensure that you update this again soon..
I saw a lot of website but I conceive this one has got something special in it. “Surfing is good for the soul, worries seems to drift away as you scan the horizon for the next wave.” by Ed Daley.
Thankyou for helping out, great information.
I would like to use the ability of saying thanks to you for the professional advice I have often enjoyed going to your site. I am looking forward to the actual commencement of my college research and the overall preparing would never have been complete without visiting this site. If I may be of any help to others, I might be ready to help by way of what I have discovered from here.
Great post, I believe website owners should acquire a lot from this weblog its real user pleasant. So much fantastic info on here :D.
Thankyou for helping out, superb information.
Thanks a ton for being my own instructor on this area. We enjoyed your article greatly and most of all cherished how you handled the areas I regarded as controversial. You are always incredibly kind to readers much like me and aid me in my existence. Thank you.
Enjoyed examining this, very good stuff, thanks . “It is well to remember that the entire universe, with one trifling exception, is composed of others.” by John Andrew Holmes.
Utterly indited content , regards for selective information .
Very interesting topic, appreciate it for posting.
I love your writing style really enjoying this web site. “Living in a vacuum sucks.” by Adrienne E. Gusoff.
I’ve recently started a web site, the information you provide on this site has helped me greatly. Thank you for all of your time & work.
Keep up the wonderful work, I read few posts on this web site and I conceive that your website is really interesting and holds circles of fantastic information.
Simply to follow up on the up-date of this subject on your web site and want to let you know simply how much I prized the time you took to publish this beneficial post. In the post, you really spoke on how to definitely handle this problem with all ease. It would be my pleasure to build up some more concepts from your web-site and come up to offer other individuals what I have learned from you. Thanks for your usual fantastic effort.
I still can not quite feel that I could end up being one of those reading the important recommendations found on this blog. My family and I are truly thankful for your generosity and for providing me possibility pursue the chosen career path. Many thanks for the important information I managed to get from your web site.
I regard something really interesting about your web site so I saved to fav.
I was studying some of your articles on this internet site and I believe this internet site is rattling instructive! Keep putting up.
I always was interested in this subject and stock still am, appreciate it for posting.
Perfectly written written content, thanks for information. “The bravest thing you can do when you are not brave is to profess courage and act accordingly.” by Corra Harris.
I like this weblog very much, Its a rattling nice post to read and receive information. “The one thing that doesn’t abide by majority rule is a person’s conscience.” by Harper Lee.
Wohh precisely what I was looking for, thanks for posting.
I believe you have remarked some very interesting points , thankyou for the post.
Howdy are using WordPress for your blog platform? I’m new to the blog world but I’m trying to get started and set up my own. Do you need any coding expertise to make your own blog? Any help would be really appreciated!
I would like to take the ability of saying thanks to you for the professional instruction I have always enjoyed going to your site. I will be looking forward to the actual commencement of my college research and the entire groundwork would never have been complete without visiting your website. If I might be of any assistance to others, I might be thankful to help through what I have gained from here.
I would like to consider the ability of thanking you for your professional suggestions I have continually enjoyed checking out your site. We are looking forward to the actual commencement of my school research and the entire preparation would never have been complete without checking out your website. If I can be of any help to others, I might be pleased to help by way of what I have learned from here.