Unable to download files from FTP server

36548900 20 Reputation points
2023-06-20T05:11:38.54+00:00

enter image description here

Problem Description: I put a file on FTP server (server created in Windows 10) so clients can download that file. The problem is that clients connected to the Internet with valid IP addresses can download this file, but clients connected to the Internet with dynamic IP addresses cannot download this file. The download operation is performed by a module written in VBA Excel. There is exactly the same problem in executing commands that are sent in the Windows command line. I have attached the image of these instructions. I don't know where the problem is. Please guide me to solve this problem. Thank you. The first image: Command lines were sent by a computer connected to the Internet with a dynamic IP, which eventually encountered an error in downloading the file. Figure 2: Command lines are sent by a computer connected to the Internet with a static IP, which ultimately results in receiving the file.


Windows Server 2019
Windows Server 2019
A Microsoft server operating system that supports enterprise-level management updated to data storage.
3,743 questions
Windows 10
Windows 10
A Microsoft operating system that runs on personal computers and tablets.
11,567 questions
Internet Information Services
Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
13,045 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,520 questions
{count} votes

Accepted answer
  1. Rich Matheisen 46,636 Reputation points
    2023-06-21T18:30:35.3166667+00:00

    This should work as a PowerShell replacement for the VB code you posted:

    Add-Type -AssemblyName PresentationFramework
    Function FtpDownload{
        param(
            [string]$RemoteFile,
            [string]$LocalFile,
            [string]$HostName,
            [string]$User,
            [string]$Pass
        )
        $ftp = "ftp://{0}:{1}@{2}{3}" -f $User,$Pass,$HostName,$RemoteFile
        $uri = New-Object -TypeName System.Uri -ArgumentList $ftp
        $webclient = New-Object -TypeName System.Net.WebClient
        $webclient.DownloadFile($uri, $File)
    }
    
    Function DownLoad{
        Try{
            FtpDownload -RemoteFile "/public_ftp/text.txt" `
                        -LocalFile  "D:\town finance/text.txt" `
                        -HostName   "server10.dn-server.com" `
                        -User       "xxxxxx" `
                        -Pass       "nnnnnn"
            [System.Windows.MessageBox]::Show("download ok","Pars Royan","OK","Information") | Out-Null
        }
        Catch{
            [System.Windows.MessageBox]::Show('fail',"Pars Royan","OK","Error") | Out-Null
        }
    }
    
    1 person found this answer helpful.

5 additional answers

Sort by: Most helpful
  1. 36548900 20 Reputation points
    2023-06-21T15:45:12.4066667+00:00

    Thank you very much to all friends who took the time to answer my question. My problem was solved with your help.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.