Use the FileSystemEntity rename() method to change the name of a file, directory or symlink. This method is inherited by File, Directory, and Link.
import 'dart:io'; main() async { // Get the system temp directory. var systemTempDir = Directory.systemTemp; // Create a file. var file = await new File('${systemTempDir.path}/foo.txt').create(); // Prints path ending with `foo.txt`. print('The path is ${file.path}'); // Rename the file. await file.rename('${systemTempDir.path}/bar.txt'); // Prints path ending with `bar.txt`. print('The path is ${file.path}'); }
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did129458