我需要将数据文件夹从Unix环境传输到网络。 一次文件传输效果很好,但不适用于文件夹。新手在这里。
**I got this code, looks great and simple:**
source = "c:\source"
$destination = "ftp://username:password@example.com/destination"
$webclient = New-Object -TypeName System.Net.WebClient
$files = Get-ChildItem $source
foreach ($file in $files)
{
Write-Host "Uploading $file"
$webclient.UploadFile("$destination/$file", $file.FullName)
}
$webclient.Dispose()
我的解释不太好:
$destination = "\\fmh-utilzz\c$\visbkups\"
$sourceftp = "ftp://userid:password@fxxxxx.com/users/gmj0687/ftptest/"
"ftp url: $sourceftp"
$webclient = New-Object System.Net.WebClient
$Sourceuri = New-Object System.Uri($sourceftp)
$files = Get-ChildItem $destination
#
foreach ($file in $files)
{
Write-Host "Downloading $file"
$webclient.DownloadFile("$destination/$sourceuri", $file.FullName)
}
$webclient.Dispose()
任何帮助都会很棒。