今天给大家带来的这个C#演示File.Move移动及重命名文件示例代码是小编为大家分享的一个C#使用File.Move移动和重命名文件的例子,使用File.Move不仅能够移动文件到新路径下,还能够顺势将文件名修改为新文件名,用起来非常的方便,是一个很实用的C#文件操作技巧,以下发上来我收藏的File.Move简单用法例子,,赶紧来详细了解一下吧:
namespace RenameFile { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button2_Click(object sender, EventArgs e) { if (textBox1.Text != textBox2.Text) { File.Move(textBox1.Text, textBox2.Text); } } private void button1_Click(object sender, EventArgs e) { openFileDialog1.ShowDialog(); textBox1.Text = openFileDialog1.FileName; textBox2.Text = openFileDialog1.FileName; } } }