I have the following code to perform FTP file:
private bool InitFTPTransfer(string filePath)
{
Uri ipAddress = new Uri(ddcdao.ddcAddress);
string ftpAddress = "ftp://10.175.95.11/mnt/flash" +Path.GetFileName(filePath);
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(ftpAddress);
request.Method = WebRequestMethods.Ftp.UploadFile;
request.Credentials = new NetworkCredential(Properties.Settings.Default.SysFTPID, Properties.Settings.Default.SysFTPPassword);
byte[] fileContents = File.ReadAllBytes(filePath);
request.ContentLength = fileContents.Length;
Stream requestStream = request.GetRequestStream();
requestStream.Write(fileContents, 0, fileContents.Length);
requestStream.Close();
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
response.Close();
return true;
}
The file transfers without a problem but the file is placed on the root, not at the designated directory (/mnt/flash).
I was under the impression that specifying a directory in ftp address should set the destination properly but this may not be true for embedded linux.
How can I fix this issue?