作成日: 2016/12/13 最終更新日: 2016/12/20
文書種別
不具合
状況
修正済み
詳細
ディレクトリを指定して一括ダウンロードを実行すると、指定したローカルルートに階層(ツリー)ではなく、パスをアンダースコア(_)で区切ったようなファイル名でダウンロードされます。
回避方法
この問題はService Pack 5(v4.7.1.0)で修正されました。
不具合を修正した最新のサービスパックは、アップデートページ からダウンロードできます。
Service Pack 5より前のバージョンでは、次の方法で回避可能です。
下記のように、ListDirectoryTreeメソッドを使用してディレクトリーリストを取得し、ファイルをひとつずつダウンロードする方法で回避できます。
◎サンプルコード(VB)
◎サンプルコード(C#)
不具合を修正した最新のサービスパックは、アップデートページ からダウンロードできます。
Service Pack 5より前のバージョンでは、次の方法で回避可能です。
下記のように、ListDirectoryTreeメソッドを使用してディレクトリーリストを取得し、ファイルをひとつずつダウンロードする方法で回避できます。
◎サンプルコード(VB)
Dim localPath As String = "c:¥temp"
Dim remotePath As String = "myFolder"
If Not Directory.Exists(localPath + "¥" + remotePath) Then
Directory.CreateDirectory(localPath + "¥" + remotePath)
End If
Dim filesToGet As List(Of ListEntry) = ftp.ListDirectoryTree(remotePath, "", False)
For Each le As ListEntry In filesToGet
If le.Type = EntryType.Directory Then
Dim dir As String = le.FullName.Replace("/", "¥")
If Not Directory.Exists(localPath + dir) Then
Directory.CreateDirectory(localPath + dir)
End If
ElseIf le.Type = EntryType.File Then
Using fs As New FileStream(localPath + le.FullName.Replace("/", "¥"), FileMode.Create, FileAccess.Write)
fs.Position = fs.Length
ftp.Get(le.FullName, fs.Position, fs)
End Using
End If
Next
Dim remotePath As String = "myFolder"
If Not Directory.Exists(localPath + "¥" + remotePath) Then
Directory.CreateDirectory(localPath + "¥" + remotePath)
End If
Dim filesToGet As List(Of ListEntry) = ftp.ListDirectoryTree(remotePath, "", False)
For Each le As ListEntry In filesToGet
If le.Type = EntryType.Directory Then
Dim dir As String = le.FullName.Replace("/", "¥")
If Not Directory.Exists(localPath + dir) Then
Directory.CreateDirectory(localPath + dir)
End If
ElseIf le.Type = EntryType.File Then
Using fs As New FileStream(localPath + le.FullName.Replace("/", "¥"), FileMode.Create, FileAccess.Write)
fs.Position = fs.Length
ftp.Get(le.FullName, fs.Position, fs)
End Using
End If
Next
◎サンプルコード(C#)
string localPath = "c:¥¥temp";
string remotePath = "myFolder";
if (!Directory.Exists(localPath + "¥¥" + remotePath))
{
Directory.CreateDirectory(localPath + "¥¥" + remotePath);
}
List filesToGet = ftp1.ListDirectoryTree(remotePath, "", false);
foreach (ListEntry le in filesToGet)
{
if (le.Type == EntryType.Directory)
{
string dir = le.FullName.Replace("/", "¥¥");
if (!Directory.Exists(localPath + dir))
{
Directory.CreateDirectory(localPath + dir);
}
}
else if (le.Type == EntryType.File)
{
using (FileStream fs = new FileStream(localPath + le.FullName.Replace("/", "¥¥"), FileMode.Create, FileAccess.Write))
{
fs.Position = fs.Length;
ftp1.Get(le.FullName, fs.Position, fs);
}
}
}
string remotePath = "myFolder";
if (!Directory.Exists(localPath + "¥¥" + remotePath))
{
Directory.CreateDirectory(localPath + "¥¥" + remotePath);
}
List
foreach (ListEntry le in filesToGet)
{
if (le.Type == EntryType.Directory)
{
string dir = le.FullName.Replace("/", "¥¥");
if (!Directory.Exists(localPath + dir))
{
Directory.CreateDirectory(localPath + dir);
}
}
else if (le.Type == EntryType.File)
{
using (FileStream fs = new FileStream(localPath + le.FullName.Replace("/", "¥¥"), FileMode.Create, FileAccess.Write))
{
fs.Position = fs.Length;
ftp1.Get(le.FullName, fs.Position, fs);
}
}
}
旧文書番号
39825