これは Microsoft のコード サンプルで、ファイルの場所が異なりますが、動作しません。
string fileName = "test1.txt";
string sourcePath = @"C:\";
string targetPath = @"C:\Test\";
// Use Path class to manipulate file and directory paths.
string sourceFile = System.IO.Path.Combine(sourcePath, fileName);
string destFile = System.IO.Path.Combine(targetPath, fileName);
System.IO.File.Copy(sourceFile, destFile, true);
ソースファイルが見つかりません。ブレークポイントを設定すると、次のようになります。
args {string[0]} string[]
fileName "test1.txt" string
sourcePath "C:\\" string
targetPath "C:\\Test\\" string
sourceFile "C:\\test1.txt" string
destFile "C:\\Test\\test1.txt" string
そのため、逐語的な文字列が使用されているにもかかわらず、バックスラッシュが 2 倍になっているように見えます。(C に test1.txt ファイルがあることは間違いありません:) 何かアイデアはありますか? ありがとう!