Efficient way to get the file list and copy to local directory?
<p>I was trying to get the list of files in my remote directory and check only the file has name "test";  then copy to my local directory.</p>

<p>Just did a simple thing here but can someone please let me know the best way to handle this scenario.</p>

<pre><code>class Program
{
    static void Main(string[] args)
    {
        var getfiles = new fileshare.Program();
        string[] filteredfiles =getfiles.GetFileList();

        bool b;
        foreach (string file in filteredfiles)
        { 
            if(b=file.Contains("test"))
            {
                getfiles.copytolocal(file);
            }

        }

    }

    private string[] GetFileList()
    {
        string[] filepaths = Directory.GetFiles(@"\\testserver\dev");
        return filepaths;
    }
    private void copytolocal(string filename)
    {
        File.Copy(filename, @"C:\" + filename);
    }
}
</code></pre>

<p>Even i just stuck up when i was copy the file,the filename contains the whole directory inside the filename so filename look like "\\testserver\dev\test.txt". So it failed to copy in to local.</p>
