save up to 40%

How to move a file from one location to another location?

Are you preparing for IT certification? With practice questions, study notes, interactive quizzes, tips and technical articles, uCertify PrepKits ensure that you get a solid grasp of core technical concepts to ace your certification exam in first attempt.

How to move a file from one location to another location?

Rating:

The steps to move a file from one location to another location are as follows:

  1. Implement the System.IO namespace as follows.

    using System.IO;

  2. Enter the source path of the file that is to be moved and the destination path where the file is to be moved.

    string source=@" d: emp est.txt ";
    string destination=@" d:\Myapp emp1 est.txt ";

  3. Check whether the source file exists. If it does not exist, create it.

    If(!File.Exists(source)
    {
    //This block is executed only when source file does not exist
       FileStream fs=File.Create(source);
    }

  4. Ensure that the target does not exist.

    If(File.Exists(destination)
    File.Delete(destination);

  5. Move the file.

    File.Move(source, destination);

  6. Close the FileStream class, if used.

    fs.Close();


Rating:



Other articles

Click here to Article home

 
uCertify.com | Our Company | Articles | Privacy | Security | Contact Us | News and Press Release | uCertify India
MCSE: MCSA, MCTS, MCITP    JAVA Certification: SCJP, SCWCD Cisco Certification: CCNA, CCENT, A+, Network+, Security+
Oracle Certification: OCP 9i, OCP 10g, OCA 9i, OCA 10g CIW foundation    EC-212-32    CISSP    Photoshop ACE    Adobe Flash ACE
© 2008 uCertify.com. All rights reserved. All trademarks are the property of their respective owners.