Renaming folder problems

  • Thread starter csharpula csharp
  • Start date
C

csharpula csharp

Hello,
I am trying to rename a folder by using
Directory.Move(soucrceFolder,destFolder) but keep getting the following
error:
Cannot create a file when that file already exists.

Why can it happen? Thanks!
 
G

Gilles Kohl [MVP]

Hello,
I am trying to rename a folder by using
Directory.Move(soucrceFolder,destFolder) but keep getting the following
error:
Cannot create a file when that file already exists.

Why can it happen? Thanks!

Quoting MSDN:

"This method throws an IOException if, for example, you try to move
c:\mydir to c:\public, and c:\public already exists. You must specify
"c:\\public\\mydir" as the destDirName parameter, provided that
"mydir" does not exist under "c:\\public", or specify a new directory
name such as "c:\\newdir"."

What are the specific values for "sourceFolder" and "destFolder" in
your case? Does "destFolder" already exist?

Regards,
Gilles.
 

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