473,511 Members | 15,408 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

moving subfolders

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
Jul 22 '08 #1
4 1794
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.
Jul 22 '08 #2
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


Jul 22 '08 #3
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" <re********@gmail.coma écrit dans le message de groupe de
discussion :
8d**********************************...oglegroups.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.

Jul 22 '08 #4
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)...
Jul 23 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4286
by: Kris | last post by:
Question: How do you create an Installer program using the Package and Deployment Wizard provided by Visual Studio Pro 6.0 (SP5) to include subfolders and their contents. I understand how to...
9
9394
by: Tom | last post by:
How do you programatically get a list of subfolders in a folder? Thanks! Tom
3
1939
by: TK | last post by:
Excuse me for multiple posting because I've posted this message to aspnet.security NG but have not got any response yet. I'm building an ASP.NET application works in Forms Authentication mode...
9
18962
by: Bill Nguyen | last post by:
I need a VB routine to loop thru a select top folder to find all subfolders and list all subfolders/files under each of these subfolders. Any help is greatly appreciated. Bill
8
2130
by: John Dann | last post by:
Just getting started with VB2005 and unsure how best to move active VB2003 projects into the VB2005 environment. Nornally I've versioned my VB2003 projects at specific development points by...
4
1901
by: Martin | last post by:
Hi! How do I move a project (all sources) to a different location. Currently it is located in 'My Documents', but I would like to move it to a directory on the server. When I try the "Save As..."...
9
2742
by: OWeb | last post by:
Javascript and recursing subfolders assistance ------------------------- I have this script that is a free extra download from SlideShowPro. It's a great script but I feel it needs to be...
0
1420
by: Artie | last post by:
I have moved SQL 2000 to new hardware several times following various 'approved' procedures with success. I have a customer who did the following and it seems to work (although very minimal...
2
12677
by: pbrown | last post by:
Hey All, My problem appears to be pretty simple. I need a way of listing all the folders that exist in a certain directory. By all the folders, I mean ALL the folders; any file folder that exists...
0
7353
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7418
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7075
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5662
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5063
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3212
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
781
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
446
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.