Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FTP file last modified VB.NET

How do you get the date modified from a file on an FTP server in visual basic?

This is what I have so far:

Dim request = CType(WebRequest.Create(URL + ZipFile), FtpWebRequest)
request.Method = WebRequestMethods.Ftp.GetDateTimestamp

I've tried a couple lines afterwards but none actually return the date.

like image 662
joyjumper Avatar asked Dec 05 '25 04:12

joyjumper


1 Answers

Well I figured it out, but I'll leave this here since I couldn't find any other vb.net posts about this:

Imports System.Net
Imports System.Globalization

Dim request = CType(WebRequest.Create(URL + ZipFile), FtpWebRequest)
request.Method = WebRequestMethods.Ftp.GetDateTimestamp
Dim response = CType(request.GetResponse(), FtpWebResponse)
Dim ServerDate = DateTime.ParseExact(response.StatusDescription.Substring(4,14),"yyyyMMddHHmmss",_
                                     Cultureinfo.InvariantCulture,DateTimeStyles.None)
like image 114
joyjumper Avatar answered Dec 08 '25 17:12

joyjumper



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!