Skip to content

Copy files from one folder to another from app.config

anusha kommawar

Asked May 14, 2014, 8:57 PM EDT1 answer
Share
LinkedInX
Hi,
 
I am having a requirement where I want to copy files from one folder to another where I should create a destination folder programatically and copy files in it and I want to do it from app.config file and don't want to specify the paths directly. As I was new to coding I don't know how to do it. Please any body tell me how to do this.
 

Thanks in advance. 

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    Step 1: Add the Source and Destination settings in app.Config

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
      <appSettings>
        <add key="SourceFolderPath" value="d:\source" />
        <add key="DestFolderPath" value="d:\dest" />
      </appSettings>
    </configuration>


    Step 2: Access the same from C# code

    string sourcepath= ConfigurationSettings.AppSettings.Get("SourceFolderPath");
    string destinationpath= ConfigurationSettings.AppSettings.Get("DestFolderPath");
    0