Last active
December 25, 2015 04:39
-
-
Save Krizzzn/6919211 to your computer and use it in GitHub Desktop.
Upload one or many files to Sharepoint
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Net; | |
WebClient webClient = new WebClient(); | |
webClient.Credentials = new NetworkCredential("*******", "********"); | |
Action<string> act = (imageName) => { | |
Console.Write("uploading " + imageName + " "); | |
webClient.Headers.Add("Overwrite", "T"); | |
webClient.UploadFile("http://*************/User%20Photos/Profile%20Pictures/" + imageName, "PUT", imageName); | |
Console.WriteLine("Done"); | |
}; | |
var currentDirectory = System.IO.Directory.GetCurrentDirectory(); | |
var files = System.IO.Directory.EnumerateFiles(currentDirectory, "*.jpg") | |
.Select(System.IO.Path.GetFileName) | |
.ToList(); | |
Console.WriteLine("uploading {0} files.", files.Count()); | |
files.ForEach(act); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment