documentsdirectory

UWP save file in Documents and Pictures Library

五迷三道 提交于 2019-12-10 11:35:56
问题 I'm trying to make a UWP app which can export a file saved in his own storage into the document library. In Package.appxmanifest I've inserted the following lines: <uap:Capability Name="picturesLibrary" /> <uap:Capability Name="documentsLibrary" /> The code to get the path is this: StorageFolder storageFolder = await KnownFolders.GetFolderForUserAsync(null /* current user */, KnownFolderId.DocumentsLibrary); string path = storageFolder.Path + "\\" + fileName; The code to save the file is this

Swift 3 - Copy Folder w/ contents from Main Bundle to Documents Directory

大兔子大兔子 提交于 2019-12-10 02:45:07
问题 I have folders with files inside them in my main bundle, and I want to copy/cut them to the Documents Directory at first launch of the application to access them from there. I've seen examples but they're all in Obj-C and I'm using Swift 3. How can I do this? 回答1: I managed to do it using 2 functions: func copyFolders() { let filemgr = FileManager.default filemgr.delegate = self let dirPaths = filemgr.urls(for: .documentDirectory, in: .userDomainMask) let docsURL = dirPaths[0] let folderPath

How to add or import multiple items to a file which saved in Documents Directory with Swift?

妖精的绣舞 提交于 2019-12-09 04:13:31
As you can see, here is how to add a word "hello" to a Test.txt (saved in Documents Directory of an app): let documentsDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first! let archiveURL = documentsDirectory.appendingPathComponent("Test").appendingPathExtension("txt") try! Data("hello".utf8).write(to: archiveURL) Suppose I have a txt or csv file (with 300 names saved one by one in line: Picture1), which is saved in iCloud Drive or somewhere. How can I add those names to the Test.txt file (saved in Documents Directory of an app) with one time, just the

How to add or import multiple items to a file which saved in Documents Directory with Swift?

断了今生、忘了曾经 提交于 2019-12-08 03:49:15
问题 As you can see, here is how to add a word "hello" to a Test.txt (saved in Documents Directory of an app): let documentsDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first! let archiveURL = documentsDirectory.appendingPathComponent("Test").appendingPathExtension("txt") try! Data("hello".utf8).write(to: archiveURL) Suppose I have a txt or csv file (with 300 names saved one by one in line: Picture1), which is saved in iCloud Drive or somewhere. How can I add