0
I’m still a junior programmer and I wonder if in VB.NET it is possible to create a series of directory checks to know if it exists (do not confuse with take the direct url and check); wanted more or less like this:
I have a way C:\Victor\Programas\Teste
, i wanted my program to check if each directory of this path exists, and if it does not exist, create the directory, then copy into this directory the file junior.txt
.
Editing
I really didn’t know that Create Directory was already part of creating the directory in case it did not.. But I have one last question if you don’t mind. 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 in case it does not exist.. But the question is this how do I get this last parent directory?
I have but that:
Dim DiretorioOriginal as String = "C:Usures\Victor\Desktop\TesteDiretorios\$Teste\Lu\Ui.txt"
The "$" is for me to use the split fear getting alone Test Lu Ui.txt << this directory will be the same as inside the program
I will copy this file to the program directory:
Dim DiretorioProgran as string = application.startup & "\TesteDiretorios\"
in the case how I will create the **test lu folder**
would be but so or so?
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
If you really want to know if there is each of them separately, divide the string by the bar, and make a loop that goes testing piece by piece. C:, C: Victor, C: Victor Programs etc.
– Bacco
Fought to answer, but I tried to make the loop and did not succeed, if you can show me but or less how I can do it, I thank.
– Vyctor Junior
I edited my reply with additional information you requested. I took the liberty of incorporating to your original question, the text posted as answer (you can edit your questions when you want to increase them).
– Miguel Angelo