Hi, I keep getting the error "The requested URI is invalid for this FTP command." when trying to upload a file from local machine to the FTP server using code below in C# 2.0. I am getting error on the bold line below.
I would appreaciate if someone can guide me to proper solution.
thanks
Mahesh
publicvoid Deliver()
{
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(destinationHost); //destination host is ftp://actual IP address/
request.Method = WebRequestMethods.Ftp.UploadFile;
request.Credentials = new NetworkCredential(userId, password);
// Copy the contents of the file to the request stream.
StreamReader sourceStream = newStreamReader(sourceDirectory + sourceFile);byte[] fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd());sourceStream.Close();
request.ContentLength = fileContents.Length;
Stream requestStream = request.GetRequestStream(); //getting error here stating requested uri is invalid for this FTP commnand.requestStream.Write(fileContents, 0, fileContents.Length);
requestStream.Close();
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
Console.WriteLine("Upload File Complete, status {0}", response.StatusDescription);response.Close();
}