Recently I got very strange issue with IO, I noticed that when I change project configuration from "Any CPU" to x64 or x86 input output stop working. I can't create any files even this simple code not working.
File.WriteAllText(@"CSVTEST.csv","test");
Not to mention another code which I use to download CSV file from 'nasdaq' website.
using (FileStream fileStream = new FileStream("StockHistoryData.csv", System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write))
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://www.nasdaq.com/api/v1/historical/" + symbol + "/stocks/2010-11-14/2020-11-14");
request.Method = WebRequestMethods.Http.Get;
request.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip;
const int BUFFER_SIZE = 16 * 1024;
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
using (var responseStream = response.GetResponseStream())
{
var buffer = new byte[BUFFER_SIZE];
int bytesRead;
do
{
bytesRead = responseStream.Read(buffer, 0, BUFFER_SIZE);
fileStream.Write(buffer, 0, bytesRead);
} while (bytesRead > 0);
}
}
}
I don't get any errors or warnings, files just are not being created.
I was thinking to change project configuration back to "Any CPU" but unfortunately I can't do it because I am using Microsoft ML library which works only on x64 or x86 configurations. So it's kinda impossible for me to stay on "Any CPU" configurations.
Maybe someone already had this problem, on internet I didn't find any information about this.
I also was thinking about change configuration dynamically but I think it's kinda bad coding. Not to mention this will not work stable