4thSpace 4thSpace - 2 months ago 5x
C# Question

"Could not find a part of the path" for windows client

I have a WPF client app. I'm try to get access to

, which I can clearly see is available. When I use File.Copy() and
as the destination, I get this error:

Could not find a part of the path

Anyone know what is wrong?


The File.Copy documentation states that destFileName is:

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

You say you are passing C:\\programdata\\. That is a directory. You have to provide the path and the file name.

For example:

File.Copy("C:\\programdata\\source.txt", "C:\\programdata\\dest.txt");