i think the file name may be incorrect but i cannot tell why this throwing this exception.
any ideas?
fileName = "c:/soapmessages/OUT/" + var_yr + var_mth + var_day + "_XXXXXXX.csv";
error:
System.Net.WebException: The requested URI is invalid for this FTP command.
at System.Net.FtpWebRequest.G
etRequestS
tream()
at XXXXXXXX.Program.Main(Stri
ng[] args) in J:\mastersource\XXXXXX\Con
soleApplic
ation2\Pro
gram.cs:li
ne 179
string ftpfullpath = Path.GetFileName(ftpFile);
FtpWebRequest ftp = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftpFile));
ftp.Credentials = new NetworkCredential(ftpUserID, ftpPassword);
ftp.KeepAlive = true;
ftp.UseBinary = true;
ftp.Method = WebRequestMethods.Ftp.UploadFile;
FileStream fs = File.OpenRead(fileName);
byte[] buffer = new byte[fs.Length];
fs.Read(buffer, 0, buffer.Length);
fs.Close();
[b] Stream ftpstream = ftp.GetRequestStream(); <--- line 179[/b]
ftpstream.Write(buffer, 0, buffer.Length);
ftpstream.Close();
Select all Open in new window
You passed wrong URI just pass ftp uri to get actual file.
for e.g.
yourfolderpath = Which is display in filezilla.
use: "ftp://httpdocs/yourfilename" or use "ftp://youerwebsitename/httpdocs/yourfilename"
Open in new window