|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
Introduction
Could not find a part of the path "<full directory path>"
It is because Using the codeTo use the provided code, add Microsoft Scripting Runtime COM object to your project references. public static void CreateDirectory(string DirectoryPath)
{
// trim leading \ character
DirectoryPath = DirectoryPath.TrimEnd(Path.DirectorySeparatorChar);
Scripting.FileSystemObject fso = new Scripting.FileSystemObjectClass();
// check if folder exists, if yes - no work to do
if(!fso.FolderExists(DirectoryPath))
{
int i = DirectoryPath.LastIndexOf(Path.DirectorySeparatorChar);
// find last\lowest folder name
string CurrentDirectoryName = DirectoryPath.Substring(i+1,
DirectoryPath.Length-i-1);
// find parent folder of the last folder
string ParentDirectoryPath = DirectoryPath.Substring(0,i);
// recursive calling of function to create all parent folders
CreateDirectory(ParentDirectoryPath);
// create last folder in current path
Scripting.Folder folder = fso.GetFolder(ParentDirectoryPath);
folder.SubFolders.Add(CurrentDirectoryName);
}
}
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||