从OneDrive共享下载文件 [英] Download file from a OneDrive share
问题描述
大家好,
我正在使用C#控制台应用程序进行测试。
我用过以下代码和我从onedrive下载了一个文件,但是这个文件是一个csv文件,但它包含HTML代码而不是实际信息。 我不确定为什么会这样? 如何从onedrive和
获取实际文件而不是链接数据。
string remoteUri =" http://www.contoso.com/library/homepage/images/" ;;
string fileName =" ms-banner.gif",myStringWebResource = null;
//创建一个新的WebClient实例。
WebClient myWebClient = new WebClient();
//使用Web资源文件名连接域。
myStringWebResource = remoteUri + fileName;
Console.WriteLine("下载文件\"{0} \"来自\" {1} \" ....... \ n \ n", fileName,myStringWebResource);
//下载Web资源并将其保存到当前文件系统文件夹中。
myWebClient.DownloadFile(myStringWebResource,fileName);
Console.WriteLine("成功下载文件\"{0} \"来自\"{1} \",",fileName,myStringWebResource);
Console.WriteLine("\ nDownloaded文件保存在以下文件系统文件夹中:\ n\t" + Application.StartupPath);
< span style =""> 我得到的回报就像HTML代码一样:
< html>
< head>
< title> Microsoft OneDrive - 随处访问文件。使用免费的Office Online创建文档。< / title>< meta name =" title" content =" Microsoft OneDrive - 随处访问文件。使用免费的Office Online创建文档。" />< meta name =" description" content ="在线存储照片和文档。从任何PC,Mac或手机访问它们。在Word,Excel或PowerPoint文档上创建并协同工作。"/>< meta property =" og:title" content =" CHX">< meta property =" og:image" content =
实际文件包含的是用户信息:
ID,Fname,LName ectt。
1,John,Doe。
谢谢
您可以使用此框架: https://www.nuget.org/packages/WLive
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
You can use this framework: https://www.nuget.org/packages/WLive
这篇关于从OneDrive共享下载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!