1

Hi I just tested around with powershell Webclient. Everthing seemed to work fine, but then i had to upload a file with a # in the name (test.#00). The File on the Server just strips the .#00. The file on the server is named "test" instead of "test.#00". The test.zip works without any problems.

Here is my Script used on Powershell Windows 10:

$webclient = New-Object System.Net.WebClient 
$localPath = "c:\temp\";
$ftp = "ftp://192.168.0.202/"

$webclient.Credentials = New-Object System.Net.NetworkCredential("admin","admin")  
$webclient.UploadFile($ftp + "test.zip",$localPath +  "test.zip") 
$webclient.UploadFile($ftp + "test.#00",$localPath +  "test.#00") 
autlunatic
  • 650
  • 7
  • 17

2 Answers2

3

Special characters as #,@,: in URLs have to be hex encoded.

where 23 is the hex value (0x23) of '#'

Character    Hex Conversion
#            %23
space        %20
@            %40
Kirill Pashkov
  • 3,118
  • 1
  • 15
  • 20
1

As @kirill mentioned, you have to hex encode the file name. You can also do this programmatically using [uri]::EscapeDataString("test.#00")

C:\> get-item .\test.#00

    Directory: C:\

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----        7/20/2017   7:23 AM              0 test.#00

C:\> $file = get-item .\test.#00
C:\> $encFileName = [uri]::EscapeDataString($file.Name)
C:\> $encFileName
test.%2300
C:\>
brendan62269
  • 1,046
  • 1
  • 9
  • 12