code to move files from directory to another directory

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi

i need the code to move files from directory to another directory on sam
local machine or to a network path, thank you.

--
Ammar S. Mitoori
IT Head QIMCO Co.
Tel : +9744831199
Mobile : +9745378400
Fax : +9744831643
 
hi thanx

but to use this should i iport a namespace or class ? and haw can i create a
new folder for that file

thank you
--
Ammar S. Mitoori
IT Head QIMCO Co.
Tel : +9744831199
Mobile : +9745378400
Fax : +9744831643
 
Pure said:
hi thanx

but to use this should i iport a namespace or class ?

You need to import the namespace System.IO, or specify the namespace by
using System.IO.File.Move.
and haw can i create a
new folder for that file

Use the Directory.CreateDirectory method to ensure that the folders
exists. All the folders in the path that doesn't already exist, are
created. Example:

string source = @"c:\source\file.txt";
string destination = @"c:\my\data\folders\file.txt";
Directory.CreateDirectory(Path.GetDirectoryName(destination));
File.Move(source, destination);
 
Back
Top