A
Anil S
Hello,
I am trying to download the file (automatically using my program) and fileName has built in date in the file name. when ever I schedule the exe file, it does not run; does anybody have any clue why it does not run?
public static void Main(string[] args)
{
DateTime dt = DateTime.Now;
string date = dt.ToString("yyyymmdd");
string fileName = "" + date + "isolf.csv";
//Console.WriteLine(fileName);
//Console.ReadLine();
string location = "http://mis.nyiso.com/public/csv/isolf/";
//string fileName2 = args[1] + "isolf.csv";
HttpWebRequest wr = (HttpWebRequest)WebRequest.Create(location+fileName);
HttpWebResponse ws = (HttpWebResponse)wr.GetResponse();
Stream str = ws.GetResponseStream();
byte[] inBuf = new byte[100000];
int bytesToRead = (int)inBuf.Length;
int bytesRead = 0;
while (bytesToRead > 0)
{
int n = str.Read(inBuf, bytesRead, bytesToRead);
if (n == 0)
break;
bytesRead += n;
bytesToRead -= n;
}
FileStream fstr = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.Write);
fstr.Write(inBuf, 0, bytesRead);
str.Close();
fstr.Close();
}
I am trying to download the file (automatically using my program) and fileName has built in date in the file name. when ever I schedule the exe file, it does not run; does anybody have any clue why it does not run?
public static void Main(string[] args)
{
DateTime dt = DateTime.Now;
string date = dt.ToString("yyyymmdd");
string fileName = "" + date + "isolf.csv";
//Console.WriteLine(fileName);
//Console.ReadLine();
string location = "http://mis.nyiso.com/public/csv/isolf/";
//string fileName2 = args[1] + "isolf.csv";
HttpWebRequest wr = (HttpWebRequest)WebRequest.Create(location+fileName);
HttpWebResponse ws = (HttpWebResponse)wr.GetResponse();
Stream str = ws.GetResponseStream();
byte[] inBuf = new byte[100000];
int bytesToRead = (int)inBuf.Length;
int bytesRead = 0;
while (bytesToRead > 0)
{
int n = str.Read(inBuf, bytesRead, bytesToRead);
if (n == 0)
break;
bytesRead += n;
bytesToRead -= n;
}
FileStream fstr = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.Write);
fstr.Write(inBuf, 0, bytesRead);
str.Close();
fstr.Close();
}