|
-
Nov 12th, 2003, 05:51 AM
#1
Thread Starter
Hyperactive Member
-
Nov 12th, 2003, 07:47 AM
#2
This is indeeed fascinating. The examples table lists "Copy a directory" and sends the you to Directory overview. Only, there is no example of copying a directory there...
You could try File.Copy to copy the directory, but I doubt it will succeed.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Nov 12th, 2003, 09:04 AM
#3
Thread Starter
Hyperactive Member
Heres a class I wrote that does the trick for my Purposes. Maybe someone else is interested in that:
Code:
public class CopyDirectory
{
string source;
string destination;
public CopyDirectory(string mySource, string myDestination)
{
if(source=="")
{
throw new Exception("Class CopyDirectory created an Exception, string source has no value!");
}
if(destination=="")
{
throw new Exception("Class CopyDirectory created an Exception, string destination has no value!");
}
source = mySource;
destination = myDestination;
Directory.CreateDirectory(destination + @"\" + source);
CopyThisFolder(source);
}
private void CopyThisFolder(string folder)
{
string [] items;
items = Directory.GetFileSystemEntries(folder);
foreach (string item in items)
{
if (Directory.Exists(item)==true)
{
Directory.CreateDirectory(destination + @"\" + item);
CopyThisFolder(item);
}
else
{
string thisFile = item.Substring(item.LastIndexOf(@"\",item.Length,item.Length),item.Length-(item.LastIndexOf(@"\",item.Length,item.Length)));
File.Copy(item,destination + @"\" + item, true);
}
}
}
}
Take Care,
Stephan
Keep Smiling - even if its hard 
Frankie Says Relax, wossname Says Yeah!
wossname:--Currently I'm wearing a gimp suit and a parachute.
C# - Base64 Blog
-
Nov 12th, 2003, 02:34 PM
#4
um why not try the DirectoryInfo class?
It's methods include:
Create()
Delete()
MoveTo()
CopyTo()
-
Nov 12th, 2003, 04:45 PM
#5
CopyTo is not listed in the VS.Net 2003 reference. I already looked.
Doesn't mean it's not there though.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Nov 13th, 2003, 03:55 AM
#6
Thread Starter
Hyperactive Member
Originally posted by DeadEyes
um why not try the DirectoryInfo class?
It's methods include:
Create()
Delete()
MoveTo()
CopyTo()
Have you tried that? Are you sure about that? My Visual Studio does not show that method! All relevant methods I have are :
CREATE();
CREATESUBDIRECTORY();
DELETE();
MOVETO();
No Copy method at all.
I am using NET FRAMEWORK v1.1.4322
and Visual Studion 2003 English version 7.1.3088
But maybe I am just to blind to find it
Thanks all,
Stephan
Keep Smiling - even if its hard 
Frankie Says Relax, wossname Says Yeah!
wossname:--Currently I'm wearing a gimp suit and a parachute.
C# - Base64 Blog
-
Nov 13th, 2003, 07:05 AM
#7
there is no CopyTo() on the directoryinfo , that only exists on fileinfo
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
-
Nov 13th, 2003, 07:15 AM
#8
Thread Starter
Hyperactive Member
Keep Smiling - even if its hard 
Frankie Says Relax, wossname Says Yeah!
wossname:--Currently I'm wearing a gimp suit and a parachute.
C# - Base64 Blog
-
Nov 13th, 2003, 08:44 AM
#9
Originally posted by dynamic_sysop
there is no CopyTo() on the directoryinfo , that only exists on fileinfo
Thanks for the correction. I was looking at a book that was talking about both classes and listed some methods, which I assumed applied to both classes.
-
Nov 13th, 2003, 09:35 AM
#10
And damn well they should.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|