我正在动态创建目录,我想将文件下载到新创建的目录:
// 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);
答案 0 :(得分: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 :(得分:1)
将您传递的相同字符串传递给CreateDirectory
将字符串放在单独的变量中并将变量传递给两个函数可能很有用。
答案 2 :(得分:1)
CreateDirectory
会返回DirectoryInfo
个对象。如果存储了返回的对象,则可以将newDirectory.FullPath
传递给下载功能。
答案 3 :(得分: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);
答案 4 :(得分:0)
我了解到DirectoryInfo对象具有FullName方法,该方法返回完整路径。我用这种方法来获取路径。
感谢大家的帮助。