private void CreateFolderStructure(DirectoryNode parentNode, DirectoryInfo di, string sourceDirectory) { DirectoryNode parentNode1 = new DirectoryNode() { Name = parentNode.HasParent ? di.Name : "" }; parentNode1.SetParent(parentNode); foreach (DirectoryInfo directory in di.GetDirectories()) { this.CreateFolderStructure(parentNode1, directory, this.source); } foreach (FileInfo file in di.GetFiles("*.*", SearchOption.TopDirectoryOnly)) { if (this.GetTypeFromExtension(file.Extension) != -1) { WebResource webResource = new WebResource() { Name = parentNode1.Combine(file.Name), DisplayName = file.Name, WebResourceType = GetTypeFromExtension(file.Extension) }; parentNode1.Resources.Add(webResource); } } parentNode.Directories.Add(parentNode1); }