フォルダー内のすべてのファイルを順番に名前を付けようとしています。 (file1、file2、file3 ... file99) 以下のコードは、すべて同じ名前が付けられているため、各ファイルを次のファイルに置き換えています。for-eachループで各ファイルの名前を順番に変更する方法
これは私がこれまで持っているものです。
string pathToFiles = sourcePath.Text
string destinationPath = destPath.Text + "\\" + FileNameTextBox.Text
DirectoryInfo dirInfo = new DirectoryInfo(pathToFiles);
foreach (var file in dirInfo.GetFiles())
{
//Write the bytes of file to the destination path
File.WriteAllBytes(@destinationPath, fileToWrite);
}
MessageBox.Show("Process completed", "Completed");
どのように私はこれを達成することができますか?
を良い。あなたは何を達成しようとしていますか?新しいファイルの名前をどのようにしたいですか? – CKII
'fileToWrite'と' @ destinationPath'とは何ですか?そのコンテンツは決して変更されません。 –
あなたが言及したいくつかの文字列を含むように投稿を更新しました。 'fileToWrite'は出力先のパスに保存する必要がある関数です。 – lostintranslation