I am still junior programmer and would like to know if in VB.NET it is possible to create a series of directory checks to see if it exists (not to confuse with handle the direct url and verify); I wanted it more or less like this:
I have a C:\Victor\Programas\Teste
path, I wanted my program to check if each directory of that path exists, and if it does not exist, create the directory, and then copy the junior.txt
file into this directory.
Editing
I did not really know that Create Directory already did the part of creating the directory in case it does not exist. But I have one last question if it is not to be bothered. My program has the function of copying this file to a certain directory, inside the program directory, as I do not need to check each one I would have to check the parent directory of the right file? to use the create directory method if it does not exist .. But the question is how do I get this last parent directory?
I have more or less this:
Dim DiretorioOriginal as String = "C:Usures\Victor\Desktop\TesteDiretorios\$Teste\Lu\Ui.txt"
The "$" is for min to use the fear split being only Test \ Lu \ Ui.txt < this directory will be the same as in the program
I'm going to copy this file to the program directory:
Dim DiretorioProgran as string = application.startup & "\TesteDiretorios\"
In case I'm going to create the folder ** test \ lu **
Would it be something like this?
Dim r as directoryinfo
r = new directoryinfo(no caso a string Teste\Lu\Ui.txt)
dim result as string = r
if system.io.directory.exists("C:Usures\Victor\Desktop\TesteDiretorios\$Teste\Lu\Ui.txt")= true then
else
system.io.Directory.createdirecory("C:Usures\Victor\Desktop\TesteDiretorios\$Teste\Lu\")
end if