HarmonyOS 鸿蒙Next 如何copyfile
HarmonyOS 鸿蒙Next 如何copyfile
copyfile的时候, 需要先open吗?
是这样
let file = fs.openSync(uriString,fs.OpenMode.READ_ONLY)
await fs.copyFile(file.fd, destUri)
还是直接
await fs.copyFile(file.fd, destUri)
是这样
let file = fs.openSync(uriString,fs.OpenMode.READ_ONLY)
await fs.copyFile(file.fd, destUri)
还是直接
await fs.copyFile(file.fd, destUri)
2 回复
直接copyfile就行
import { BusinessError } from '[@kit](/user/kit).BasicServicesKit';
let srcPath = pathDir + "/srcDir/test.txt";
let dstPath = pathDir + "/dstDir/test.txt";
fs.copyFile(srcPath, dstPath, 0).then(() => {
console.info("copy file succeed");
}).catch((err: BusinessError) => {
console.error("copy file failed with error message: " + err.message + ", error code: " + err.code);
});
更多关于HarmonyOS 鸿蒙Next 如何copyfile的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html