List root folder.
SessionOptions sessionOptions1 = new SessionOptions
{
Protocol = Protocol.Ftp,
HostName = "webserver",
UserName = "webguest",
Password = "1",
};
using (Session session = new Session())
{
// Connect
session.Open(sessionOptions1);
//List files
string remotePath = ""; <---Problem here
RemoteDirectoryInfo directoryInfo = session.ListDirectory(remotePath);
//See last file
directoryInfo.Files.OrderBy(p => p.LastWriteTime).ToArray();
string strfilename = directoryInfo.Files.First().FullName;
//Copiar o ultimo
status.Text = strfilename;
string exePath = Application.StartupPath;
exePath = exePath + "\\MyFiles\\";
tempPath = exePath + "img_1.bmp";
session.GetFiles(strfilename, tempPath,false);
...
...
If I want to enter the root folder of the ftp server what should I write in remotePath?
Also, i used directoryInfo.Files.OrderBy to order by time, is there a way to filter the files like only retrieve the *.bmp files?
Thanks
{
Protocol = Protocol.Ftp,
HostName = "webserver",
UserName = "webguest",
Password = "1",
};
using (Session session = new Session())
{
// Connect
session.Open(sessionOptions1);
//List files
string remotePath = ""; <---Problem here
RemoteDirectoryInfo directoryInfo = session.ListDirectory(remotePath);
//See last file
directoryInfo.Files.OrderBy(p => p.LastWriteTime).ToArray();
string strfilename = directoryInfo.Files.First().FullName;
//Copiar o ultimo
status.Text = strfilename;
string exePath = Application.StartupPath;
exePath = exePath + "\\MyFiles\\";
tempPath = exePath + "img_1.bmp";
session.GetFiles(strfilename, tempPath,false);
...
...
If I want to enter the root folder of the ftp server what should I write in remotePath?
Also, i used directoryInfo.Files.OrderBy to order by time, is there a way to filter the files like only retrieve the *.bmp files?
Thanks