Reputation: 14161
I am using VS-2008 [C#] with .NET 3.5 SP1 installed.
I am writing an auto-update utility for my application. I want to connect via FTP and search for the files on the remote server. I want to check the versions of the local and remote file. As expected, if new files are on server, display alert.
I started with following code:
FtpWebRequest ftpRequest = (FtpWebRequest)WebRequest.Create("ftp://ftp.mysite.com//myFiles");
try
{
ftpRequest.Credentials = new NetworkCredential("new user", "new password");
ftpRequest.Method = WebRequestMethods.Ftp.GetDateTimestamp;
DateTime FtpFileLastModified = ((FtpWebResponse)ftpRequest.GetResponse()).LastModified;
}
catch (Exception)
{
throw;
}
I want to know which is a recommended method to perform this type of task in .NET 3.5 SP1
. Please illustrate with a little code.
Upvotes: 2
Views: 236
Reputation: 1585
You can use FileSystemWatcher Class- Listens to the file system change notifications and raises events when a directory, or file in a directory, changes.
Upvotes: 1