Add an interface (say IFileHandler
) which defines the contract for the getting of the remote file, then implement what you currently have, to get from a network drive, behind one implementation of that interface (say called NetworkFileHandler
).
Then create a second implementation (say FtpFileHandler
) of that interface that gets the file from FTP site. In the second implementation you give the extra information (username and password) to the constructor of the FtpFileHandler
class.
Then to change the app to do one or the other you just need to change which implementation of the interface you use.
This would then allow you to add other ways of getting the file in the future like BitTorrentFileHandler
for getting files from a bittorrent source or NntpFileHandler
for downloading the files from a newsgroup.
The interface IFileHandler could look something like:
interface IFileHandler
{
void SaveFileLocally(string sourceFile, DirectoryInfo targetLocation);
}
although exactly what it should look like will depend on what you need to do.