+7 771 559 26 76
sguruapp@gmail.com
Меню
×
Мобильные
приложения
Курсы по
программированию
Цены
на услуги
Наши
контакты
Guru
music
Блоги
Новости
Отзывы
Скопировать файл из пакета(Bundle.main) в путь назначения (каталог документов) - Copy from file (Bundle.main) to document directory - Swift 5
func CopyFilesToDocumentDirectory
(){
let bundlePath
= Bundle.main.
path
(
forResource
: "document",
ofType
: ".json")
let destPath
=
NSSearchPathForDirectoriesInDomains
(.
documentDirectory
, .userDomainMask,
true
).first!
let fileManager
= FileManager.
default
let fullDestPath
= URL(fileURLWithPath: destPath).appendingPathComponent("document.json")
if fileManager.fileExists
(
atPath
: fullDestPath.
path
){
print
("Database file is exist")
print
(fileManager.fileExists(
atPath
: bundlePath!)
)
}
else
{
do
{
try
fileManager
.
copyItem
(
atPath
: bundlePath!,
toPath
: fullDestPath.path)
print
("My doc path: \(
fullDestPath
.path)")
}
catch
{
print
("\n",error)
}}}
Возврат к списку
обучись профессии будущего
Хочешь стать успешным разработчиком
приложений? Тогда добро пожаловать к нам.
Позвоните мне