2011-08-25 71 views
0

我在飛行中創建目錄,我想將文件下載到新創建的目錄:下載在C#中的文件到新創建的目錄

// The code to create the directory based on revision number and original name 
System.IO.Directory.CreateDirectory(@"C:\Users\bob\Desktop\Hello\Files\" + "v" + fileInfo.RevisionNumber + "_" + fileInfo.OriginalName); 

// This method downloads files and takes 4 parameters. 
// The only one that really matters is the second one, targetFolder, 
// which is a String value. Any idea on how I can download the files 
// to the newly created directory (above) using the method below? 
ecm.RetrieveFile(fileInfo.ID, targetFolder, recreateDirectoryStructureFlag, overwriteWithoutPromptFlag); 

回答

1

CreateDirectory返回DirectoryInfo對象。如果存儲返回的對象,則可以將newDirectory.FullPath傳遞給下載功能。

4
var targetFolder = @"C:\Users\bob\Desktop\Hello\Files\" + "v" + fileInfo.RevisionNumber + "_" + fileInfo.OriginalName; 
System.IO.Directory.CreateDirectory(targetFolder); 
ecm.RetrieveFile(fileInfo.ID, targetFolder, recreateDirectoryStructureFlag, overwriteWithoutPromptFlag); 
1

傳遞您傳遞給CreateDirectory相同的字符串。
將字符串放入單獨的變量並將變量傳遞給兩個函數可能很有用。

0
string targetFolder= System.IO.Directory.CreateDirectory(@"C:\Users\bob\Desktop\Hello\Files\" + "v" + fileInfo.RevisionNumber + "_" + fileInfo.OriginalName).FullName; 

ecm.RetrieveFile(fileInfo.ID, targetFolder, recreateDirectoryStructureFlag, overwriteWithoutPromptFlag); 
0

我知道DirectoryInfo對象有一個返回完整路徑的FullName方法。我用這種方法來獲取路徑。

謝謝大家的幫助。

相關問題