Questions tagged [nsfilemanager]
The NSFileManager class enables you to perform various generic file-system operations and insulates an application from the underlying file system.
1,451
questions
0
votes
0
answers
44
views
How to save data in document directory without replacing previous one
I am new in swift macos development,
I am using this code but it is used to replace previous one but i want not to replace,
I want to add new and also want to contain previous
thanks in advance
let ...
-1
votes
1
answer
42
views
Swift relativePath property that FileManager.default.enumerator outputs is full path
I want to get relative paths, but I get full paths in the following code.
Xcode 14.3
let homePath = NSHomeDirectory()
let homeURL = URL(fileURLWithPath: ".", relativeTo: URL(...
0
votes
0
answers
42
views
Copy image to temp folder but failed to read
I have issue on copy image to a temp folder then read out from this. I can copy the image to the temporary folder ( with no error thrown). I trying to read out the item list in folder. The error i ...
1
vote
0
answers
48
views
Logging to a file in shared container iOS
I'm studying iOS push notifications (user facing). I have done the following steps:
Requested User's permission to show notification
Registered for remote notifications and obtained the device token.
...
0
votes
0
answers
77
views
Swift's FileManager.default.url not creating files, keeps throwing errors
I've written these two function
func locallySave(_ data: Data?, for utility: Utility) throws {
var fileURL = try FileManager.default.url(for: .applicationSupportDirectory,
...
0
votes
1
answer
41
views
Permission error when saving to documentDirectory
I am trying to save favourites to document directory, the code works fine when I run it in simulator however when I build it to my device I am getting the following error.
You don’t have permission ...
0
votes
0
answers
29
views
iOS file system directory data not persisting between builds, will it persist between App Store updates? [duplicate]
I am saving a movie file in an iOS documents directory. The file is saved fine and I can access and play it after it has been saved. But when I rebuild the project I can't access the file, when I ...
0
votes
1
answer
45
views
Text file can't be created inside a folder
I'm trying to create a log.txt file inside a folder of a device, but I get this error:
NSCocoaErrorDomain Code=512 "The file “log.txt” couldn’t be saved in
the folder “Logs”.
The folder Logs ...
1
vote
1
answer
50
views
URLResourceValues not working for renaming a file
I have to rename some files in a directory in the Documents directory. I'm trying with URLResourceValues:
let fileURLs = try! FileManager.default.contentsOfDirectory(at: directory, ...
0
votes
0
answers
103
views
is the temporaryDirectory of FileManager automatically removed by iOS? if so when?
I am adding an option in my App to backup everything to a file.
For that, I am serializing all my objects to a dictionary that I save in a single file in the path provided by FileManager.default....
0
votes
0
answers
73
views
How to move files from inside app to outside
I try to move files from documentDirectory to SD Card(connected using a card reader and Lightning). I use UIDocumentPickerViewController. If I move a single file and it exists inside the destination ...
-1
votes
1
answer
26
views
Has the behavior of copyItemAtPath changed under Ventura? Returning "file doesn't exist"
My app creates a working file in the Application Support folder at launch, and subsequently saves that file in a user preferred folder (specified in preferences as a path). The save code is very ...
0
votes
1
answer
240
views
How to download PDF using URL in iOS app multiple times
I am getting getting multiple PDF urls from server response and showing them in tableview with download option for each cell.
I am able to download each pdf file only once, But, Tried to second time ...
0
votes
1
answer
66
views
cannot access app group folder in intent handler
I have the following code in an intent handler for a widget I am creating:
extension FileManager {
static var appGroupURLAsText: String {
`default`.containerURL(forSecurityApplicationGroupIdentifier:...
-1
votes
1
answer
48
views
How do i save video to new directory in ios?
I'm working with filemanager. So far I'm able to initialize my directory but when I try to save data there, the error i get is "error: Cannot create file".There seems to be an issue with the ...
1
vote
1
answer
308
views
How to download CSV file from the web with dowload URL Swift
So I need to get the data from a google sheet (which I'm trying to generate the link for, not sure), but I have a dummy link which works. I wrote this code to download the CSV file from the ...
0
votes
1
answer
46
views
Creating a temporary txt file, from a String, to use as an NSSharingService item?
When the user is confronted with an unexpected error, I'm providing them with the option to send the error log contents as an email body of an NSSharingService item as such:
let errorLog = "[...
0
votes
0
answers
49
views
Am i doubling the amount of time it takes for the video to upload (from user's camera roll)?
In one of my view controllers, I'm using PHPickerViewController. When I get my results, I then upload the URL to Firebase. It works fine, but with this line of code, try! FileManager.default.copyItem(...
0
votes
0
answers
50
views
Iterate through local Swift packages
I have a bunch of local Swift packages in my project. Some of them are third party, but I have made some modifications to them to suit my needs. I want to display them in a list of acknowledgements in ...
0
votes
1
answer
78
views
Persisting with FileManager is producing unique urls at every app launch in Simulator
I want to persist data, images and otherwise. I read that saving to files is especially recommended for larger data. I followed relevant parts of this tutorial: https://developer.apple.com/tutorials/...
0
votes
1
answer
55
views
How to access user selected folder in iOS
I'm looking for an iOS API that allows accessing a user-selected folder in place (without importing it). It seems to be possible with native frameworks from Apple. How I expect it to work:
User ...
0
votes
0
answers
22
views
FileManager doesn't have permission to access Music directory [duplicate]
I am making a music player and want to store and access the .mp3 files from the users Music directory under my app's own sub folder. I use this code to get the directory:
let documentDirectory = try ...
-1
votes
2
answers
2k
views
Different path URL for FileManager everytime I open the app [duplicate]
I want to create one folder in the fileManager root path, but before creating it, I want to check that the folder exist or not, and if not, I will create, otherwise will leave it
here are the function ...
2
votes
1
answer
161
views
Why is my Swift app created text file visible/accessible in the simulator, but not the iOS device itself?
I would like my Swift app to be able to write a file (myDebug.log) that is viewable by a user on their iOS device.
The code I am using is below. While the code can be cleaner and more efficient, right ...
0
votes
0
answers
19
views
MacOS FileManager can't open Safari History.db [duplicate]
From this article, http://2016.padjo.org/tutorials/sqlite-your-browser-history/,
I learned you can open Safari's History.db in ~/Library/Safari
I'm trying to query the Safari's History.db in Swift and ...
0
votes
0
answers
97
views
Copy image files without changing creation and modified dates
I have a method that copies images and videos the user selected from the iOS photo library to a temporary cache folder (under the app's Documents directory) but image files that are JPEG or TIFF have ...
0
votes
0
answers
130
views
NSFileManager moveItemAtPath does not work
I am using https://www.tutorialspoint.com/objective_c/objective_c_file_handling.htm as a reference to move a file to another directory but it is not working. There is no error. I added the code to see ...
-1
votes
1
answer
79
views
While loop with NSFileManager directory enumerator not running
I am seeking help to understand why a tutorial I am following is not working for me. I am running macOS 12.3.1, Xcode 13.3.1. The project is in Objective-C and using XIB.
This is a view-based ...
0
votes
1
answer
568
views
Swift: FileManager().fileExists(atPath: (fileURL.path)) without knowing extension
)
today I have a problem and I can't find an easy solution.
With:
FileManager().fileExists(atPath:(fileURL.path))
it's simple to find out if a file exist. Actually I have the file name but don't know ...
0
votes
1
answer
64
views
how to get the rest of path from sub folder
I have a path like :
file:///private/var/mobile/Containers/Data/Application/80C93A3C-DFB5-4756-8DC8-7ED34469EA11/Documents/allFiles/81B5D904-CCEC-4B92-BD9B-4175BF6A99BC.jpeg
The thing that I am ...
1
vote
0
answers
177
views
How do I get the number of bytes written during a copy/move process using FileManager?
I want to show a progress indicator when conducting FileManager tasks such as moveItem and/or copyItem calls.
Can Progress be used to monitor FileManager's progress? If so, can someone give me some ...
0
votes
0
answers
25
views
Swift photo loaded from file rotated 90 degrees [duplicate]
I'm taking UIImages and sending them over iOS' Multipeer framework. Here's the steps I take to do so:
/// Save images to filesystem before sending over Multipeer
func save(image: UIImage) -> ...
1
vote
0
answers
18
views
Case Sensitive FileManager.default.fileExists(atPath:) [duplicate]
When I on my Mac run
FileManager.default.fileExists(atPath: path)
the resulting check is case-insensitive. So filePath will return the same as FiLePaTh. I need it to do a case-sensitive check however....
1
vote
1
answer
215
views
renderer.writePDF doesn't work without error
I learn swift and faced with problem: when i try write pdf file in document directory nothing happened.
Code:
func createPDF() {
// MARK: - create path
let documentDir = FileManager....
1
vote
0
answers
68
views
How to ignore cache when repeatedly reading from disk
I am writing an app that contains a small benchmark for I/O operations.
For write operations, I am using a 'FileHandle' which works pretty well. I am testing my old USB stick and my calculation ...
0
votes
1
answer
170
views
When is ubiquitous container deleted?
I'm playing with iCloud Drive Documents/ubiquitous containers to share documents between devices my app is installed on.
So far, everything seems to work fine. I can manage documents, get notified ...
0
votes
0
answers
540
views
Tracing file creation via dynamic analysis of iOS application (using Frida)
Using FRIDA (http://frida.re), I'm debugging/reverse engineering an iOS app. The aim is to trace every file or folder created on the device by the app during runtime. So far I've tried running this ...
1
vote
1
answer
279
views
Sorting arrays of file attributes by their creation date in Swift
I have been using Swift's [enumerator(at:includingPropertiesForKeys:options:)]1 to find all files within a given base path and create arrays for different resource keys (file name, path, creation date,...
0
votes
2
answers
1k
views
Get the name of file(s) within last directory and the full directory path using Swift
I am trying to obtain the name of a file (JSON format but saved without an extension) within the last directory of a given path. Each file is saved with its own unique subpath inside the app's data ...
1
vote
0
answers
729
views
Swift -Get/Save RelativePath for URL
I save some audio. The path to the url is
"/Users/abc/Library/Developer/CoreSimulator/Devices/C6751406-604F-4AF4-8D3F-DA26E208632D/data/Containers/Data/Application/7255C72B-F194-49F6-A73D-...
1
vote
1
answer
488
views
Unable to access Files, because there is no such file or directory
Good Day.
I receive a message with an image URL. Whenever I receive the image URL I have to show it through local notification. Like this
However, I use UNNotificationAttachment
convenience init(...
4
votes
0
answers
113
views
macOS check if file is available offline (gdrive, dropbox, one drive, nexcloud)
When iterating over files I must check whether or not the file is available offline if the drive is a virtual drive, for example.
When working with GDrive's "stream files" feature, files in ...
0
votes
0
answers
322
views
Swift 5: iOS 15 FileManager – How to obtain the URL to the "Shortcuts" directory/folder in iCloud?
I am writing an iOS 15 app (no need to worry about anything prior to iOS 15) that operate will between other processes in a workflow.
I need to be able to list/find files whose names will start with a ...
0
votes
0
answers
82
views
iOS Caches Directory handling relational files
I store certain files in the caches directory of my application because I want Apple to decide when to delete the files and I do not want them to be backed up.
However, some of these files relate to ...
1
vote
1
answer
261
views
FileManager: Attribute for when a file was last opened
I need a way of checking when a file was last opened. I tried by creating a custom FileAttributeKey and setting that to the current Date, but when I go to open the file again the attribute does not ...
0
votes
1
answer
126
views
NSFileManager createDirectoryAtPath method returns true but no directory was created
In my app, I want to create a directory and put some txt files in it. Here is my code to create the directory
-(BOOL)createFolderInDocuments:(NSString *)folderName
{
NSError *error = nil;
...
0
votes
1
answer
202
views
Trying to duplicate file tree as in Files app
I am trying to get to the file system directory similar to the Files app on iOS or the Finder on MacOS and don't seem to be getting the expected results.
On the iOS simulator I get the MacOS ...
1
vote
0
answers
185
views
How to prevent file name conflict when saving UIDocument to new URL without FileManager
Using FileManager it is possible to check if a file exists using the FileManager method fileExists(atPath:) when saving files to the App Sandbox.
However, when working directly with UIDocument the ...
0
votes
1
answer
142
views
How to write multiple image files iteratively to documents folder in swift swiftui ios
@ObservedObject foldersData = FoldersViewModel()
func genThumbnails() -> Void {
for ind in subDirNames.indices{
for indd in galContents[ind].indices{
if ...
1
vote
1
answer
1k
views
Choose destination when saving file
Is it possible to make user able to choose a destination for the file that he wants to download, something like DocumentPicker which you can use when choosing a file to upload?
I want something like ...