Modify the file name
// modify the file name Private void the button1_Click ( Object SENDER, EventArgs E) { string = textBox1.Text oldfilename; // original file path FileInfo FINFO = new new FileInfo (oldfilename); // get files FileInfo object // new file path string = oldfilename.Substring newfilename ( 0 , oldfilename.LastIndexOf ( " \\ " )) + " \\ " + textBox2.Text.Trim () + oldfilename.Substring (oldfilename.LastIndexOf ( " . " )); finfo.MoveTo (newfilename);// move the file }
Delete Files
// delete files / * need to use the Delete method of FileInfo objects when deleting files, which permanently delete files. * * * / Private void Secret010_Load ( Object SENDER, EventArgs E) { // method of the FileInfo FINFO = new new the FileInfo ( @ " D: \ 123 \ 1.txt " ); finfo.Delete (); // Method Two File. the Delete ( @ " D: \ 123 \ 1.txt " ); }