powershell 在连接ftp后怎么断开连接


PowerShell交流中心分类: Powershell基础powershell 在连接ftp后怎么断开连接
0
momoko_glad asked 7年 ago

powershell 在连接ftp后怎么断开连接
在我完成文件上传后,没有关闭进程,我想改FTP上的文件夹发现不能修改,应该是FTP连接还未断开,望大神解惑!!!
拜谢!!!
代码如下:
$fileName = “2122sdzdasds.CSV”
$Source = “d:\aa.log”
$Destination = “ftp://xxxxxxxxx” + $fileName
$R=[System.Net.FtpWebRequest][System.Net.WebRequest]::Create($Destination)
$R.Credentials = New-Object System.Net.NetworkCredential(“xxxxx”, “xxxxx#2014”)
$R.Method = “STOR”
$FileContens = [System.IO.File]::ReadAllBytes($Source)
$S = $R.GetRequestStream()
$S.Write($FileContens, 0, $FileContens.Length)
$S.Close()
$S.Dispose()

EricGeng replied 7年 ago

这是在powershell使用.NET的对象么?

momoko_glad replied 7年 ago

是的 ,我已经解决了