Brand new to StackOverflow.... I'm writing a console app in C#. I'd like to verify that an Excel spreadsheet is streaming correctly using FTP.
The application calls a stored procedure, populates a datatable with the result set, reads the datatable into a stream and then FTP's that stream onto a 3rd party site. I'd like to upload the stream somewhere besides that actual 3rd party site just to verify everything shows properly on the other end. Looking for help with how to do that.
I've tried setting up a local FTP but received the following error when trying to create the FTPWebRequest:
"The requested URI is invalid for this FTP command."
FtpWebRequest myWebRequest = (FtpWebRequest)WebRequest.Create("ftp address");
I also tried Console.Out with no luck.
This is what my code to upload looks like:
StreamReader sourceStream;
using (sourceStream = new StreamReader(path))
{
fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd());
}
myWebRequest.ContentLength = fileContents.Length;
using (Stream requestStream = myWebRequest.GetRequestStream())
{
requestStream.Write(fileContents, 0, fileContents.Length);
}
using (FtpWebResponse response = (FtpWebResponse)myWebRequest.GetResponse())
{
Console.WriteLine($"Upload File Complete, status {response.StatusDescription}");
}