moving subfolders

F

fixertool

using visual studio 2005, framework 2.0, winXP SP2
I have a winform with two text-boxes, both associated with a folder
browser dialog (no problem with this), and a button.
First text-box has the origin folder, and the other points to the
destination one.
Aditionally, I have a "backup" folder.
The CONTENT of the origin folder is copied into destination's. But
first, I have to move all the destination content to a new subfolder
inside "backup".
When I'm talking of the Content of a folder, I'm meaning all the
archives and subfolders (with all its content) inside that folder.
The problem is when I try to move destination content to the newly
created subfolder (inside backup), Destination folder disappears.
This is the code (very simple as you may see)

Imports System.IO
Imports System.Diagnostics
// not using other references

Directory.CreateDirectory(BackupSubFolder)
//created inside BackupFolder (no problem with this)
If Directory.Exists(destinationFolder) Then
// destination content is moved here. But after this,
destinationFolder disappears...
Directory.Move(destinationFolder, BackupFolder)
Else
MessageBox.Show("BackupSubFolder Not Created")
End If
 
F

fixertool

I need to clarify something. The line
Directory.CreateDirectory(BackupSubFolder) is useless, in fact.
Because when you try
Directory.Move(destinationFolder, BackupFolder), BackupFolder is
created, if not before. And if it already exists, a proper exception
is launched.
But the main problem still remains: Why destinationFolder disappears,
in spite of its content appear inside BackupFolder?
I want destinationFolder remains intact. Empty, without its content
now moved to backupFolder, but without disappearing.
 
F

fixertool

Thanks for your kind response. I'll see this later. And I'll post my
solution.

Ah ! So what you want is to move the *content* of this folder (of
course you
can use GetFiles/GetDirectories to get the content)...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top