Results 1 to 3 of 3

Thread: [RESOLVED] Moving Files Problem

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Dunmow,Essex,England
    Posts
    898

    Resolved [RESOLVED] Moving Files Problem

    Hi ALL,

    I'm using C#4.0

    When I try to run the following :

    Code:
    File.Move(@file, @ConfigurationManager.AppSettings["CompletedFolder"]);
    I receive the error:

    Cannot create a file when that file already exists.

    However the files do not exist in the destination folder.

    Any ideas?

  2. #2
    Cumbrian Milk's Avatar
    Join Date
    Jan 2007
    Location
    0xDEADBEEF
    Posts
    2,448

    Re: Moving Files Problem

    Assuming you have double checked everything I would hazard a guess that the command expects a full path for the destination (or perhaps a destination terminated with a backslash). I think it is currently interpreting the destination folder as the new name for the file.
    W o t . S i g

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Dunmow,Essex,England
    Posts
    898

    Re: Moving Files Problem

    Yes, You are right, it wasn't enough for me to just give a destination folder. I needed to give it the name of the file as well.......

    Code:
    foreach (string @file in workLockton)
                        {
                            String[] fileName = file.Split('\\');
    
                            File.Move(@file, @ConfigurationManager.AppSettings["CompletedFolder"] + "\\" + fileName.Last());
                        }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width