How to move file to a new location and rename in C#

1 Answer

0 votes
using System;
using System.IO;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string file = @"d:\data.txt";

            try
            {
                File.Move(file, @"d:\development - tools\data.bak"); // move and reanme

                Console.WriteLine("Move successes");
                
            }
            catch (IOException ioex)
            {
                Console.WriteLine(ioex.Message);
            }
        }
    }
}

/*
run:
   
Move successes

*/


answered Mar 17, 2015 by avibootz

Related questions

1 answer 146 views
146 views asked Aug 22, 2023 by avibootz
1 answer 189 views
189 views asked Aug 26, 2015 by avibootz
4 answers 410 views
410 views asked Mar 15, 2015 by avibootz
1 answer 107 views
107 views asked Aug 12, 2023 by avibootz
3 answers 305 views
1 answer 156 views
156 views asked Sep 6, 2014 by avibootz
...