I am creating directories on the fly and I would like to download files to the n开发者_Python百科ewly created directory:
// 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);
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);
CreateDirectory
returns a DirectoryInfo
object. If you store that returned object, you can then pass newDirectory.FullPath
to the download function.
Pass the same string that you passed to CreateDirectory
.
It may be useful to put the string in a separate variable and pass the variable to both functions.
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);
I learned that the DirectoryInfo object has a FullName method that returns the full path. I used this method to get the path.
Thanks all for the help.
精彩评论