I have some files located at my document folder. i am savong the files like "data_20201223163209.pdf", "data_20201223171831.pdf", "data_20201222171831.pdf", "data_20201221171831.pdf" etc. now i want to replace "data" with other strings like "newdata". so my files should be "newdata_20201223163209.pdf", "newdata_20201223171831", "newdata_20201222171831", "newdata_20201221171831"
My code is:-
do { let path = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] let documentDirectory = URL(fileURLWithPath: path) let originPath = documentDirectory.appendingPathComponent("data") let destinationPath = documentDirectory.appendingPathComponent("newdata") try FileManager.default.moveItem(at: originPath, to: destinationPath) } catch { print(error) }
Please help me to to resolve this issue
https://stackoverflow.com/questions/65433140/to-change-file-name-in-document-folder-in-swift December 24, 2020 at 10:05AM
没有评论:
发表评论