4thSpace 4thSpace - 1 year ago 74
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?

Answer Source

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");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download