File I/O And Registry :: Using Recursive Function For Directory Tree?
Dec 2, 2008
I am trying to write code to save (in a text file) a list of folders/files that are contained in a specified folder. I want the list to be formatted to illustrate the folder tree structure by indenting sub-folders and there related files according to their relationship to the base folder.
I found and incorporated a recursive function for listing file & folders. This works fine for generating the list, but I am having difficulty with code to determine the sub-directory level relative to the base folder. the code that I have included below sort of works.......The problem seeme to be when going from a folder that is multiple levels up? from the base to one that is only one level from the base. Refer to my sample output. This should not be as difficult as I seemed to have made it, but recursion kinda blows my mind.
Code:
' The following function call is in a button handler
GetFilesFolders(txtBaseFolder.Text)
Public Sub GetFilesFolders(ByVal path As String)
[code]....
View 2 Replies
ADVERTISEMENT
Mar 2, 2012
I'm hoping to improve the performance of the below as well as return the GUID of each user.
I've converted and modified the code found here for searching through groups recursively to get all the members and their details and adding them to a class collection. However I also need to capture the user's managers details so I'm calling the AD twice for each user. This doesn't seem efficient as many of the users will have the same manager. It would seem logical to get the distinct manager details from the collection class and call only these, then replace them wherever they occur in the collection.
I'd also like to be able to get the user's GUID, I've tried accessing it directly as a property of the collection, but it doesn't return anything.
I'm using vs2005 and .Net 2.0
Public Class ADCLass
''' <summary>
''' Calls recursive function to return users in group
[Code]....
View 1 Replies
Feb 11, 2012
I am currently using a recursive function to retrieve all the files/folders within a directory.Sometimes this takes a while. I am wondering if I am able to calculate the total number of files/folders within a directory before retrieving the filenames so that I can implement a progress bar?
View 1 Replies
Oct 22, 2009
I want to search a directory and get all the names of the "Folders" within that directory and place them into a string array. Note: No Files just folders
View 3 Replies
Jan 17, 2008
I have been working with getting a recursive directory list function going and an attempt that I was considering doesn't seem to work.As it doesnt seem to return all folders.
Public aFolderList As New System.Collections.ArrayList()
Sub recurseDirs(ByVal sPath As String)
Dim dirInfo As DirectoryInfo = New DirectoryInfo(sPath)
Dim subDirs As DirectoryInfo
[code]....
View 9 Replies
Sep 24, 2008
It keeps throwing an exception like this "Cannot create a file when that file already exists" at this line:
Code:
Directory.Move(contentDirectory, archiveDirectory)
I have checked, and the directory that I am moving, does exist at the source, but does not exist at the destination. I have tried including some console.writelines to make sure my variables are correct, and they look good. The first bit of code works where it creates the new directory, but fails when I try to move anything over to that directory.
Code:
Sub Main()
Dim Guid As String = "test"
Dim archiveName As String = "scripttestone"
Dim contentDirectory As String = "C:content" & Guid
Dim archiveDirectory As String = "C:archive" & archiveName
Dim TodaysDate As Date = Now()
[Code] .....
View 5 Replies
Apr 9, 2011
I wrote some code yesterday which shows a directory listing of an FTP server and if you click on a folder it will show that directory and their is a back button. But I dont think it is efficient and I can tell there will be a lot of errors.
Imports SylentUpload.Utilities.FTP
Public Class Form3
Private DirectoryHistory As String = "/"
Private DecryptedUsername As String
Private DecryptedPassword As String
[Code] .....
View 3 Replies
Apr 12, 2011
I have to map a directory with all subdirectories and their subdirectories and so on, all in a treeview.
I have this code but it has a "small" bug, is not done well.
[Code]...
View 4 Replies
Dec 29, 2009
I am writing a program that needs to be able to copy a directory from C:Folder to a folder inside My Documents.I am aware of the My.Computer.FileSystem.SpecialDirectories.MyDocuments which places the directory in the root of My Documents. I however, want to copy the said folder to 'My DocumentExampleFolderFolder1'
View 1 Replies
Jul 15, 2009
I wrote a cleanup program to go through some directories and delete files based on if the creation date is older than say 6 months. It works fine with some of the directories I have that contain around a few thousand small files. However, there is one directory (that contains small backup files from another program) that is loaded with over 300,000 files and it locks up on me as soon as I read in the first file in that directory.I am convinced it is the directory has too many files in it to open it. The server that the directory is on is slow. It takes a half hour to open the directory while on the server itself. I know it will take forever to delete the amount of files I want to delete, but I don't understand why it gets stuck and hangs there with no error message.Here is where I get stuck. Listbox1 is the directory I'm attempting to access
For Each selectFile In My.Computer.FileSystem.GetFiles(ListBox1.Items.Item(Count), FileIO.SearchOption.SearchTopLevelOnly, "*.*")
compFile = Path.GetFileName(selectFile)
[code].....
View 6 Replies
Jun 7, 2012
I have the below code that (not sure exactly where I found it) I am trying to add a recursive rename to all files in the directory. Currently, this code only does a folder at a time, however, I need it to go through all the folders and change all files.
Private Sub StripXfromBeginning(ByVal strip As Integer)
Dim JustFileName As String
Dim attributes As FileAttributes
GetFileArray()
For Each fileNameToProcess In FileList
[Code] .....
View 3 Replies
Mar 19, 2009
I am using the following Recursive Directory Copy code, and am having a strange issue. I am using this to copy and directory and all subdirectories and files to removable media (flash drive). Everything copies perfectly fine except for 1 file. this occurs on the same file every time and sometimes the file copies successfully, but other times it does not.The problem file is a 7-zip archive with a .7z file extension.When it does not successfully copy, the file is only 8 bytes on the flash drive.[code]
View 5 Replies
Jun 1, 2009
I have this code to delete a registry key:
Private Sub RemoveCurrentKey(ByVal name As String)
Dim key As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\", True)
key.DeleteSubKeyTree(name)
End Sub
But it simply wont remove the key tree, How do I remove the whole tree?
View 4 Replies
May 9, 2006
I'm a developer for a College we have an active directory.I need to query Active Directory with the Pc name and return it's path in the Active Directory tree.
View 3 Replies
Nov 20, 2009
Can someone explain to me what the difference is between a recursive function and a factorial function. I know that a factorial function returns the product of all the numbers from 1 to itself. But how does that differ from what a recursive function does
View 2 Replies
Nov 28, 2011
I am hopeing someone can help me here with a recursive function I have that is not returning either true or false as I would have espected it to. The function loops through a Active Directory group for its members and then calls itself if it encounters any groups within the membership in order to gets its members as well. I am trying to return either true or false based on if any errors were encountered but not haveing any luck at all. It appears to just hang and never return back to the primary calling sub that starts the recursive function. Below is my code I am using:
[Code]...
View 1 Replies
Jan 17, 2011
I have the following data in this a table
ID ParentID Active Node
1 0 1 <RCExtRequest>?</RCExtRequest>
[Code]....
If changing the table layout would make this any easier then I could so that.
View 2 Replies
Feb 11, 2011
i have these 2 functions that search for any .jpg files starting from a given path the algorithm works, it's just that it freezes up the gui at times this is why i wish to know how to implement it through a new thread or a backgroundworker maybe.[code]
View 2 Replies
Mar 12, 2011
I'm making a program that can mark my shooting cards and i have created it and it works nicely But i want to get as much speed out of it as possible so I switched my target CPU to X64 and sure enough my recursive function threw a Stack overflow exception telling me i need to make sure i don't have Infinity recursions. Strangely when I set It back to X86 the same recursive function works...
vb.net
Dim bullethole As New List(Of Point)
Function GetBulletHole(ByVal point As Point) As Point()
[Code]....
View 12 Replies
Nov 21, 2009
Is it possible to use a recursive function on an array
If I have an array like this[code]...
I want to use a recursive function to make in out like this[code]...
View 4 Replies
May 8, 2010
I am trying to find a way to allow my users to choose the directory to save files into, THe file name is automatically generated as it has a naming convention and i am able to pre program a location to save to but i d like to be able to allow my users to decide themselves which directory they want to save the files to and to have the ability to choose which directory to save to
[Code]...
View 2 Replies
Mar 5, 2009
We have installed on our vista system winzip: WinZip Command Line Support Add-On Version 2.2.We are using vb2008 and want to run wzzip.exe from the shell function. "C:Program FilesWinZipWZZIP.EXE" -m d:my.zip d:info*.*
For a few files it's working great but when the d:info has a great number of files, only the wzzip dos screen is visible and the program don't goes further. Does someone has experience with this problem and has a solution?
View 3 Replies
Aug 13, 2009
I am trying to find a quick, step by step tutorial on on to implement a tree view for my intranet that will show all the computer accounts in my domain. (this is obliviously only step number one, because once i can see them, I want to be able to query information from them.but one thing at a time right?)
View 1 Replies
Apr 21, 2009
I am loading the directories from my C drive into a treeview using the code below. It takes forever due to the number of folders. Is it possible to have this only populate down 1 level and then use a NodeMouseClick Event to drill down further, in the same treeView, if the user desires to do so? How would I amend this code to do this?
[Code]...
View 5 Replies
Dec 8, 2009
I have a recursive function in this function i am adding some value to path variable here i want to acess this value outside of function for this what changes i will do in this function.
Private Sub GeValuePath(ByVal ParentID As Integer)
Try
dim path as string =""
[Code]......
View 1 Replies
Feb 11, 2010
have an xml file like this.
<?xml version ="1.0" encoding ="utf-8"?>
<menu>
<menuNode title="Register" value="true">
[Code]....
View 2 Replies
Feb 14, 2011
I have 3 variables. Lets call it "a", "b" and "c". These 3 variables can "independently" have 3 different values. Lets say: "1", "6" and "10". when you think of them as combination; there are (3^3) 27 combinations. I am told that it can be done through the recursive functions. However i am not a good developer to handle with that. Would u please help me?
- 3 variables and 3 different values are simplified. In fact; the numbers of variables and different values can vary.
- i know only the language, visual basic in .net; please don't answer in other coding languages.
additional note: i am going to put the these combinations in the string format into a collection.. for example "1;1;1", "1;6;1", "1;6;10".. and so on..
View 7 Replies
Aug 16, 2011
I have a recursive function wich objective is scan an structure and represent that structure with treenodes. Inside my function depends the structure I'll have to create another treenode inside my treenode or just create a node. My problem is that I don't know how to remember my treenode position when I have to call my function again.
If strTop.TextString.ToUpper = "DMN" Then
gcTreeno.Nodes.Add("Node")
Else
Dim perf As New TreeNode
gcTreeno.Nodes.Add(perf)
End If
if i would like to write next time a node into perf, how i could do it?
View 1 Replies
Nov 21, 2009
How can I use a recursive function to remove a character from a string thats stored in a array.
Like so
MMMMM
MMMM
MMM
MM
M
I need to remove a letter from the string each time it loops through the string until there is only 1 letter left in the string.
View 7 Replies
Jan 1, 2010
is there a tool that can display the directory tree on a form like a treeview?
View 3 Replies