I want to get the results of a stored procedure and place them into a CSV file onto an FTP location.
The catch though is that I cannot create a local/temporary file
If you were allowed to implement CLR integration assemblies you could actually use FTP without having to write a temporary file:
public static void DoQueryAndUploadFile(string uri, string username, string password, string filename)
{
FtpWebRequest ftp = (FtpWebRequest)FtpWebRequest.Create(uri + "/" + filename);
ftp.Method = WebRequestMethods.Ftp.UploadFile;
ftp.Credentials = new System.Net.NetworkCredential(username, password);
using(StreamWriter sw = new StreamWriter(ftp.GetRequestStream()))
{
// Do the query here then write to the ftp stream by iterating DataReader or other resultset, following code is just to demo concept:
for (int i = 0; i < 100; i++)
{
sw.WriteLine("{0},row-{1},data-{2}", i, i, i);
}
sw.Flush();
}
}