2
Answers

move file from one folder to another folder in c#

Asad khan

Asad khan

8y
304
1
how to move file from one folder to another folder in c#?
Answers (2)
0
Karthik Elumalai

Karthik Elumalai

NA 5.4k 309.2k 8y
Hi Asad khan:
Hope the below code and link ,will help you in the right direction
Sample Program:-
C# program that renames files with File.Move
class Program
{
static void Main()
{
//
// Move a file found on the C:\ volume.
// If the file is not found (SAM.txt doesn't exist),
// then you will get an exception.
//
try
{
File.Move(@"C:\SAM.txt", @"C:\SAMUEL.txt"); // Try to move
Console.WriteLine("Moved"); // Success
}
catch (IOException ex)
{
Console.WriteLine(ex); // Write error
}
}
}
other Resources:
http://www.dotnetperls.com/file-move
http://www.c-sharpcorner.com/forums/move-file-from-one-folder-to-other
Kindly let me know if it was useful
Thanks
karthik
0
Bheem Sen Yadav

Bheem Sen Yadav

NA 111 6.3k 8y
UseFile.Move(sourceFileName,destFileName);
For reference check
https://msdn.microsoft.com/en-us/library/cc148994(v=vs.100).aspx
https://msdn.microsoft.com/en-us/library/system.io.file.move(v=vs.110).aspx