code to move files from directory to another directory

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
 
G

Guest

Pure said:
hi

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

Use the File.Move method.
 
G

Guest

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
 
G

Guest

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);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top