Download file from a OneDrive share

  • Thread starter Thread starter KSS113
  • Start date Start date
K

KSS113

Guest
Hello all,


I am using a C# Console application for testing.


I have used the following code and I have downloaded a file from onedrive, but this file is a csv file but it contains HTML code and not the actual information. I am not sure why this is? How do I get the actual file from onedrive and not what seems to be link data.


string remoteUri = "http://www.contoso.com/library/homepage/images/";
string fileName = "ms-banner.gif", myStringWebResource = null;
// Create a new WebClient instance.
WebClient myWebClient = new WebClient();
// Concatenate the domain with the Web resource filename.
myStringWebResource = remoteUri + fileName;
Console.WriteLine("Downloading File \"{0}\" from \"{1}\" .......\n\n", fileName, myStringWebResource);
// Download the Web resource and save it into the current filesystem folder.
myWebClient.DownloadFile(myStringWebResource,fileName);
Console.WriteLine("Successfully Downloaded File \"{0}\" from \"{1}\"", fileName, myStringWebResource);
Console.WriteLine("\nDownloaded file saved in the following file system folder:\n\t" + Application.StartupPath);

What I am getting back is like HTML code:

<html>
<head>
<title>Microsoft OneDrive - Access files anywhere. Create docs with free Office Online.</title><meta name="title" content="Microsoft OneDrive - Access files anywhere. Create docs with free Office Online."/><meta name="description" content="Store photos and docs online. Access them from any PC, Mac or phone. Create and work together on Word, Excel or PowerPoint documents."/><meta property="og:title" content="CHX"/><meta property="og:image" content=

What the actual file contains is user information:

ID, Fname, LName ectt.

1, John, Doe.


Thanks

Continue reading...
 
Back
Top