Search code examples
powershellftp-client

Getting Date from a file on a remote FTP Server


To get a file, the Method looks like this:

$ftprequest.Method = [System.Net.WebRequestMethods+Ftp]::DownloadFile  

So, I am trying to change the Method to be equivalent to the C# code below:

request.Method = System.Net.WebRequestMethods.Ftp.GetDateTimestamp;

How can I use GetDateTimestamp in powershell?

I have tried the following variations without any luck yet:

$ftprequest.Method = [System.Net.WebRequestMethods+Ftp.GetDateTimestamp]
$ftprequest.Method = [System.Net.WebRequestMethods+Ftp+GetDateTimestamp]
$ftprequest.Method = [System.Net.WebRequestMethods.Ftp.GetDateTimestamp]
$ftprequest.Method = [System.Net.WebRequestMethods.Ftp+GetDateTimestamp]

bonus question: what is the :: mean on the first code example mean?

Thanks!


Solution

  • This seems to work:

    $ftprequest.Method = [System.Net.WebRequestMethods+Ftp]::GetDateTimestamp
    

    :: is to access shared/static members, which GetDateTimeStamp is.