Hi
I use this code now:
Dim
theDirectories() As String = Directory.GetDirectories("\\server\kursister$\" & combohvem.SelectedItem & u2) For Each currentDir As String In theDirectories My.Computer.FileSystem.MoveDirectory(currentDir, "\\server\vaerksted$\" & combohvem.SelectedItem & u2 & "_" & dato & "\", True) NextBut if my folder maybe is images and i in this folder have 3 folders 1 - 2 - 3 then the code moving the 1 - 2 - 3 folders and then i get an error, and my images folder remains back why
reagrds
alvin

error again in moving folders
DQM
Hi
Thanks for the answer
What i want is to move the folder from 1 to 2
I have made this in VBA and here i copy the folder and all files
from 1 to 2 , and then i delete all folders in 1, i understand i can't delete
a folder if i'm inside the folder, but again how do i get out off the folder and
delte the folder
Regards
Alvin
j_o_h_a_n_n_e_s
well it will give you a denied error if you are currently still holding reference/instance of the folder you are currently in which you are trying to delete.
I guess you could catch the exception and let it go but may not be best practice, since you obviously want to delete the foler.
Jassim Rahma
I have solve it
Alvin
cheesetarmac
If the directory is in use you will get an error...
What is the error message
Scott Boyd
Hi
My folder name images
in this folder i have maybe 3 folders
then if i use the code, its moving the 3 folders in the images folder but not the images folder
So my directorie is not in use
want i want is moving the images folder with the 3 folders to another place , not the 3 folders alone
regards
alvin
MLyons10
http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=664519&SiteID=1
is this not the same
fgarzonhz
hi,
i am currently working on something similar to your problem. could you tell me how did you slove the problem of geting out of the folder and delete the folder after copying the folder to another destination
thanks
=)
Ronaldlee Ejalu
Hi!
I have use this:
Private
Sub cdmslet_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cdmslet.ClicktheErrorCounter = 0
fejl.ListBox1.Items.Clear()
Dim i As Integer Dim taltekst As String For i = newtal To newtal2 If i < 10 Thentaltekst =
"0" & i Elsetaltekst = i
End If
My.Computer.FileSystem.CopyDirectory("//Kursist/kursister/" & Comboslettype.SelectedItem & taltekst, "//kursist/vaerksted$/" & Comboslettype.SelectedItem & taltekst & "_" & newstring, True) Dim theFolders() As String = Directory.GetDirectories("\\kursist\kursister\" & Comboslettype.SelectedItem & taltekst)
If theFolders.Length > 0 Then
'copy/delete your files here
For Each currentFolder As String In theFolders
TryDirectory.Delete(currentFolder,
True) Catch ex As IOExceptiontheErrorCounter = theErrorCounter + 1
Dim newVal As String = Comboslettype.SelectedItem & taltekst If Not fejl.ListBox1.Items.Contains(newVal) Then fejl.ListBox1.Items.Add(newVal) End Try Next
End IfNext
If theErrorCounter > 0 Thenfejl.Show()
ElseMsgBox(
"Flytning / sletning af mapper skete uden fejl ")hovedmenu.Show()
Me.Hide()
End If
End SubMattDude
Yes and no
First i believe its working , but then if i have more folders in my folders it dosn't work
My.Computer.FileSystem.CopyDirectory("\\server\kursister$\" & combohvem.SelectedItem & u2 & "\", "\\server\vaerksted$\" & combohvem.SelectedItem & u2 & "_" & dato & "\", True) My.Computer.FileSystem.DeleteDirectory("\\server\kursister$\" & combohvem.SelectedItem & u2 & "\", FileIO.DeleteDirectoryOption.DeleteAllContents)Now i use this:
This code works by copy but when it comes to delete i get a denied error
Is there a way to get pas this
Alvin