moving/renaming directory to 2 levels below

D

Daves

why the heck can't I use Directory.Move() to rename a directory (containing
files) to a entry 2 levels below e.g.

uploads/tempfiles
-> uploads/tempfiles/48/003files

if I do this in one line it says "part of the file name not found" bla bla
so I move it in two steps but then in the second step it says "the file is
being used by another process"

Is this impossible to do????


ps i'm using c#/asp.net 2.0
 
N

Nicholas Paldino [.NET/C# MVP]

Daves,

This is more a logic issue than anything.

If you want to move uploads/tempfiles (directory included), then you are
basically eliminating the directory.

If anything, you need to copy the files over, and not the whole
directory. You can't just "expand" a path in that way.

What you should do is in the uplocats/tempfiles directory is to take all
the files and all of the directories, and copy them to new subdirectories
that you create.

Hope this helps.
 
D

Daves

well I need to MOVE it not copy, I simplified the code below, actually I'm
moving
"~/uploads/Forums/tempfiles123412"

to

"~/uploads/Forums/102/43files"

(the folder name refers to ForumID and MessageID)

Nicholas Paldino said:
Daves,

This is more a logic issue than anything.

If you want to move uploads/tempfiles (directory included), then you
are basically eliminating the directory.

If anything, you need to copy the files over, and not the whole
directory. You can't just "expand" a path in that way.

What you should do is in the uplocats/tempfiles directory is to take
all the files and all of the directories, and copy them to new
subdirectories that you create.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Daves said:
why the heck can't I use Directory.Move() to rename a directory
(containing files) to a entry 2 levels below e.g.

uploads/tempfiles
-> uploads/tempfiles/48/003files

if I do this in one line it says "part of the file name not found" bla
bla so I move it in two steps but then in the second step it says "the
file is being used by another process"

Is this impossible to do????


ps i'm using c#/asp.net 2.0
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

Daves said:
well I need to MOVE it not copy, I simplified the code below, actually I'm
moving
"~/uploads/Forums/tempfiles123412"

to

"~/uploads/Forums/102/43files"

Well this is a complete different scenario, just create the dir and move the
files, you create the dir path using Directory.CreateDirectory, this will
create ALL the levels, then you move the files over
 

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