File.Copy target file is a directory, not a file.

c#

Solution

You should add the filename to the target path. This is clearly specified in the documentation: http://msdn.microsoft.com/en-us/library/c6cfw35a.aspx

The name of the destination file. This cannot be a directory or an existing file.

For example:

"J:\Project\Project\HotelDB.accdb"

Should go to:

"c:\HotelDB.accdb"

(And not `"C:\"`)

Problem

I am probably not doing this correctly, and browsing the MSDN library hasn't helped me much. I am trying to copy my database from my project folder to another location. I initially tried the desktop, and it stated the directory was not available. This is what I currently have. ``` private string currentDb = @"J:\Project\Project\HotelDB.accdb", backUpPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), newFileName = @"\"; ``` I call it with this method. The error I currently get is that the Environment.SpecialFolder.MyDocuments class indicates that 'My Documents' is a folder, not a file. This tells me that I'm doing this all wrong. Any guidance is appreciated. ``` public void backupDatabase() { File.Copy(currentDb, backUpPath, true); } ```

Original source