I need to test an internet file ...
I need to test an internet file ...
17 Sep 2015, 08:35
I need to test an internet file. Please help me with the right code. Thank you!
using System; using cAlgo.API; using cAlgo.API.Internals; using cAlgo.Indicators; using cAlgo.API.Requests; using System.IO;
namespace cAlgo.Robots
{ [Robot("TestFile", AccessRights = AccessRights.Internet)]
public class TestFile : Robot
{
private string myFileName;
protected override void OnStart()
{
myFileName = Path.Combine("http://www.pauna.biz/8052756.txt");
}
protected override void OnTick()
{
if (!File.Exists(myFileName)) Stop();
}
}
}
Replies
moneybiz
17 Sep 2015, 11:35
To download something from internet you need to use WebClient.
Add the following using statement to the top, which includes the WebClient class:
using System.Net;
Then inside your OnStart() method you can download the content of the file as follows:
var client = new WebClient(); var content1 = client.DownloadString("http://www.pauna.biz/8052756.txt"); var content2 = client.DownloadString("http://www.pauna.biz/8052756.txt"); if (content1.Contains("8052756")) { // Do something. }
That's it.
@moneybiz
cristianpauna
17 Sep 2015, 11:49
RE:
Thank you very much indeed !!!
moneybiz said:
To download something from internet you need to use WebClient.
Add the following using statement to the top, which includes the WebClient class:
using System.Net;
Then inside your OnStart() method you can download the content of the file as follows:
var client = new WebClient(); var content1 = client.DownloadString("http://www.pauna.biz/8052756.txt"); var content2 = client.DownloadString("http://www.pauna.biz/8052756.txt"); if (content1.Contains("8052756")) { // Do something. }
That's it.
@cristianpauna
Spotware
17 Sep 2015, 08:51
Dear Trader,
We do not provide coding assistance services. We more than glad to assist you with specific questions about cAlgo.API. You also can contact one of our Partners or post a job in Development Jobs section for further coding assistance.
@Spotware