locked
How to copy filename with space RRS feed

  • Question

  •  

    Hi all,

     

    I had a file name : "test 123.dat" and is in dir A

     

    May I know how to copy this file with spaces to dirB?

     

    Thanks

     

     

     

     

    Friday, February 29, 2008 4:47 AM

Answers

  •  

    I do not understand that u r talking about c# or command prompt thats the reason i am going to write for both

    for c# use this code

    File.Copy(@"A:\test 123.dat", @"B:\test 123.dat");

     

    for command prompt

    C:\>copy "A:\test 123.dat" "B:\test 123.dat"

     

    Friday, February 29, 2008 5:09 AM

All replies

  •  

    I do not understand that u r talking about c# or command prompt thats the reason i am going to write for both

    for c# use this code

    File.Copy(@"A:\test 123.dat", @"B:\test 123.dat");

     

    for command prompt

    C:\>copy "A:\test 123.dat" "B:\test 123.dat"

     

    Friday, February 29, 2008 5:09 AM
  • In C#? Simply File.Copy:

     

        File.Copy("test 123.dat", @"c:\test 123.dat");

     

    If you mean "at the command line", then you'll need to put quotes around the 2 arguments:

     

    copy "test 123.bat" "c:\test 123.dat"

     

    etc

    Friday, February 29, 2008 5:10 AM