简体   繁体   English

如何使用C#Web服务在PhoneGap中下载任何文件

[英]How to download any file in PhoneGap using C# Webservice

I have no idea of how to download a file using a C# web service. 我不知道如何使用C#Web服务下载文件。

Please help me with the following C# code. 请使用以下C#代码帮助我。

var fileTransfer = new FileTransfer();
var uri = encodeURI("http://some.server.com/File.docx");

fileTransfer.download(
    uri,
    downloadPath,
    function(entry) {
        console.log("Download compelete: " + entry.fullPath);
    },
    function(error) {
        console.log("Download error source " + error.source);
        console.log("Download error target " + error.target);
        console.log("Upload error code" + error.code);
    },
    false
);

But I don't want to give a URL like this. 但我不想提供这样的网址。 I want to download through Webservice. 我想通过Webservice下载。 Is it possible? 可能吗?

Your question is very vague. 您的问题非常模糊。 I would suggest adding more details to try and get more answers. 我建议添加更多详细信息以尝试并获得更多答案。 I can make the following recommendations for you to look into: 我可以提出以下建议供您研究:

  1. Cordova File Plugin - This plugin allows your cordova app to mess with the files on the mobile's devices disk. Cordova File Plugin-此插件可让您的cordova应用程序破坏手机设备磁盘上的文件。 Ie this lets you read and write files locally. 即,这使您可以在本地读取和写入文件。
  2. Cordova File Transfer Plugin - This plugin allows you to connect to remote services (for example your C# service) and download files from them. Cordova File Transfer插件 -此插件可让您连接到远程服务(例如C#服务)并从中下载文件。
  3. Cordova White List Plugin - This is essential if you want to connect to external websites and services. Cordova白名单插件 -如果要连接到外部网站和服务,这是必不可少的 Without this plugin and without defining your whitelist in config.xml you will not be able to connect to anything remotely. 没有这个插件,也没有在config.xml定义白名单,您将无法远程连接任何东西。

I would also recommend looking at this and this for more info. 我还建议在看这个这个获取更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM