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

Re: moving subfolders by fixertool

fixertool
Tue Jul 22 12:45:41 CDT 2008

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.

Re: moving subfolders by Patrice

Patrice
Tue Jul 22 12:44:12 CDT 2008

> Directory.Move(destinationFolder, BackupFolder)

This is expected as you *move* the folder (i.e. you take it from one place
and put it at some other place)

You want likely to *copy* the folder instead :
http://msdn.microsoft.com/en-us/library/xz2d9afk.aspx

--
Patrice





Re: moving subfolders by Patrice

Patrice
Tue Jul 22 13:09:38 CDT 2008

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

--
Patrice


"fixertool" <replyfixer@gmail.com> a écrit dans le message de groupe de
discussion :
8d4c52be-4d7a-479d-bca7-309990b69ff0@27g2000hsf.googlegroups.com...
> 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.



Re: moving subfolders by fixertool

fixertool
Wed Jul 23 09:59:46 CDT 2008

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)...