{"action":"closed","issue":{"url":"https://api.github.com/repos/tathamoddie/System.IO.Abstractions/issues/95","labels_url":"https://api.github.com/repos/tathamoddie/System.IO.Abstractions/issues/95/labels{/name}","comments_url":"https://api.github.com/repos/tathamoddie/System.IO.Abstractions/issues/95/comments","events_url":"https://api.github.com/repos/tathamoddie/System.IO.Abstractions/issues/95/events","html_url":"https://github.com/tathamoddie/System.IO.Abstractions/issues/95","id":55202314,"number":95,"title":"File.Copy(string, string, bool) Should Throw DirectoryNotFoundException","user":{"login":"seth-orell-volusion","id":5082706,"avatar_url":"https://avatars.githubusercontent.com/u/5082706?v=3","gravatar_id":"","url":"https://api.github.com/users/seth-orell-volusion","html_url":"https://github.com/seth-orell-volusion","followers_url":"https://api.github.com/users/seth-orell-volusion/followers","following_url":"https://api.github.com/users/seth-orell-volusion/following{/other_user}","gists_url":"https://api.github.com/users/seth-orell-volusion/gists{/gist_id}","starred_url":"https://api.github.com/users/seth-orell-volusion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seth-orell-volusion/subscriptions","organizations_url":"https://api.github.com/users/seth-orell-volusion/orgs","repos_url":"https://api.github.com/users/seth-orell-volusion/repos","events_url":"https://api.github.com/users/seth-orell-volusion/events{/privacy}","received_events_url":"https://api.github.com/users/seth-orell-volusion/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-01-22T20:10:04Z","updated_at":"2015-01-25T01:11:07Z","closed_at":"2015-01-25T01:11:07Z","body":"There is a discrepancy between the behavior of `System.IO.File.Copy()` and the behavior of `System.IO.Abstractions.TestingHelpers.MockFile.Copy()`. In the .NET library, if any part of the path of its second argument (destFileName) does not exist, it will throw a `DirectoryNotFoundException`. The code in MockFile's `Copy()` leads to an `AddFile()` that will create any missing directories automatically.\r\n\r\nI would expect similar exceptions if the destination directory path does not exist in full.\r\n\r\nFor example, the following code will throw if you set up the source directory with an empty file and do not create the destination directory:\r\n```C#\r\nvar filePath = @\"C:\\PathThatExists\\fileName.txt\";\r\nFile.Copy(filePath, @\"C:\\PathThatDoesNotExist\\fileName.txt\", true);\r\n```"}}