1. <legend id='KLmle'><style id='KLmle'><dir id='KLmle'><q id='KLmle'></q></dir></style></legend>

      <small id='KLmle'></small><noframes id='KLmle'>

      <i id='KLmle'><tr id='KLmle'><dt id='KLmle'><q id='KLmle'><span id='KLmle'><b id='KLmle'><form id='KLmle'><ins id='KLmle'></ins><ul id='KLmle'></ul><sub id='KLmle'></sub></form><legend id='KLmle'></legend><bdo id='KLmle'><pre id='KLmle'><center id='KLmle'></center></pre></bdo></b><th id='KLmle'></th></span></q></dt></tr></i><div id='KLmle'><tfoot id='KLmle'></tfoot><dl id='KLmle'><fieldset id='KLmle'></fieldset></dl></div>

      • <bdo id='KLmle'></bdo><ul id='KLmle'></ul>

        <tfoot id='KLmle'></tfoot>

        使用 WebClient 在 PowerShell 脚本中将 FTP 从二进制更

        时间:2023-06-04
            <legend id='eg80S'><style id='eg80S'><dir id='eg80S'><q id='eg80S'></q></dir></style></legend>
              <bdo id='eg80S'></bdo><ul id='eg80S'></ul>

                <i id='eg80S'><tr id='eg80S'><dt id='eg80S'><q id='eg80S'><span id='eg80S'><b id='eg80S'><form id='eg80S'><ins id='eg80S'></ins><ul id='eg80S'></ul><sub id='eg80S'></sub></form><legend id='eg80S'></legend><bdo id='eg80S'><pre id='eg80S'><center id='eg80S'></center></pre></bdo></b><th id='eg80S'></th></span></q></dt></tr></i><div id='eg80S'><tfoot id='eg80S'></tfoot><dl id='eg80S'><fieldset id='eg80S'></fieldset></dl></div>
              • <tfoot id='eg80S'></tfoot>

                    <tbody id='eg80S'></tbody>

                  <small id='eg80S'></small><noframes id='eg80S'>

                  本文介绍了使用 WebClient 在 PowerShell 脚本中将 FTP 从二进制更改为 ascii的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  简单的 PowerShell 脚本.它下载一个文件(二进制)没有问题.我需要它在ASCII中.

                  Simple PowerShell script. It downloads a file (in binary) with no issues. I need it in ascii.

                  $File = "c:	empftpfile.txt"
                  $ftp = "ftp://myusername:mypass@12.345.6.78/'report'";
                  $webclient = New-Object -TypeName System.Net.WebClient;
                  $uri = New-Object -TypeName System.Uri -ArgumentList $ftp;
                  $webclient.DownloadFile($uri, $File);
                  

                  推荐答案

                  WebClient不支持ascii/text FTP模式.

                  The WebClient does not support ascii/text FTP mode.

                  使用 FtpWebRequest 而是设置 .UseBinary 为假.

                  Use FtpWebRequest instead and set .UseBinary to false.

                  $File = "c:	empftpfile.txt"
                  $ftp = "ftp://myusername:mypass@12.345.6.78/'report'";
                  
                  $ftprequest = [System.Net.FtpWebRequest]::Create($ftp)
                  
                  $ftprequest.Method = [System.Net.WebRequestMethods+Ftp]::DownloadFile
                  $ftprequest.UseBinary = $false
                  
                  $ftpresponse = $ftprequest.GetResponse()
                  
                  $responsestream = $ftpresponse.GetResponseStream()
                  
                  $targetfile = New-Object IO.FileStream($File, [IO.FileMode]::Create)
                  
                  $responsestream.CopyTo($targetfile)
                  
                  $targetfile.close()
                  

                  参考:在 PowerShell 中自动化安全 FTP 的最佳方法是什么?

                  请注意,WebClient 在内部使用 FtpWebRequest,但不公开其 .UseBinary 属性.

                  Note that the WebClient uses the FtpWebRequest internally, but does not expose its .UseBinary property.

                  这篇关于使用 WebClient 在 PowerShell 脚本中将 FTP 从二进制更改为 ascii的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  <small id='rdvnv'></small><noframes id='rdvnv'>

                    <tbody id='rdvnv'></tbody>
                  <legend id='rdvnv'><style id='rdvnv'><dir id='rdvnv'><q id='rdvnv'></q></dir></style></legend>

                    <i id='rdvnv'><tr id='rdvnv'><dt id='rdvnv'><q id='rdvnv'><span id='rdvnv'><b id='rdvnv'><form id='rdvnv'><ins id='rdvnv'></ins><ul id='rdvnv'></ul><sub id='rdvnv'></sub></form><legend id='rdvnv'></legend><bdo id='rdvnv'><pre id='rdvnv'><center id='rdvnv'></center></pre></bdo></b><th id='rdvnv'></th></span></q></dt></tr></i><div id='rdvnv'><tfoot id='rdvnv'></tfoot><dl id='rdvnv'><fieldset id='rdvnv'></fieldset></dl></div>

                    • <bdo id='rdvnv'></bdo><ul id='rdvnv'></ul>
                    • <tfoot id='rdvnv'></tfoot>