TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Zoltan Kerenyi
NA
72
13.3k
Download only the new file from FTP server
Dec 1 2020 4:30 PM
Hi,
Im trying to devise an algorithm for a remote FTP folder, since as far as I know it is not an easy task to mount a remote ftp in windows environment and c sharp.
So in every 2-3 minute I would log into the FTP shared folder (qnap) and search for the latest files and folders.
An event triggering is not possible since the remote shared folder is not mounted locally. So I would maintain a file list of the previous probe, and look for the difference, and only download the diff.
But the first obstacle is when listing the remote directory. 1 file is a string of attributes and the file name. Do you have a solution to this sproblem?
Thanks,
Zolee
here is the code so far:
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(
"ftp://192.168.50.100/FolderA"
);
request.Credentials =
new
NetworkCredential(
"user"
,
"pass"
);
request.Method = WebRequestMethods.Ftp.ListDirectoryDetails;
request.KeepAlive =
false
;
request.UseBinary =
true
;
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
Stream responseStream = response.GetResponseStream();
StreamReader reader =
new
StreamReader(responseStream);
//List<string> files = new List<string>();
List<
string
> files = reader.ReadToEnd().Split(
new
string
[] {
"\r\n"
}, StringSplitOptions.RemoveEmptyEntries).ToList();
reader.Close();
response.Close();
foreach
(var item
in
files)
{
Console.WriteLine(item);
Reply
Answers (
2
)
My password unmasking is working but not the way I want it to
Show Data using Modal.