Retrieving updated files from server to replace files on documents folder of an iPhone
Date : March 29 2020, 07:55 AM
Any of those help you can use NSUrlRequest to download the files, to move them to the correct place you can use NSFileManager, if you look at the apple docs for both these classes there should be sample code explaining how to copy/save a file from NSData, and also how to download it.
|
Write a list of files in the Documents folder and keep them in memory
Date : March 29 2020, 07:55 AM
seems to work fine U can save NSArray in Document Directory like this. Note : saving and retrieving filename remains same. //check favourite saved in doc dir
if(!saved) //not saved
//NSMutableArray has not data first time
//[NSMutableArray addObject:newFavourite];
//save new data in doc dir
else // saved
//firstly retrieve data from doc dir as NSMutableArray
//[NSMutableArray addObject:newFavourite];
//Now save again NSMutableArray in doc dir.
|
How to delete files from a folder which is placed in documents folder
Date : March 29 2020, 07:55 AM
wish helps you You can use the below code to delete the file from document directory: NSError *error;
NSFileManager *fileMgr = [NSFileManager defaultManager];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *documents= [documentsDirectory stringByAppendingPathComponent:@"YourFolder"];
NSString *filePath = [documents stringByAppendingPathComponent:@"file2.txt"];
[fileMgr removeItemAtPath:filePath error:&error]
|
UWP : How to get a list of all the text file names from a sub folder of Documents folder
Tag : chash , By : Jim Davis
Date : March 29 2020, 07:55 AM
To fix the issue you can do If you want to access Documents folder, you can use FolderPicker or KnownFolders.DocumentsLibrary method. About FolderPicker, you need to access folders by interacting with a picker, but you can directly choose the folder you want to. About KnownFolders.DocumentsLibrary method, you need to add extra broadFileSystemAccess capability and allow your app to access file system in settings. //FolderPicker
var folderPicker = new Windows.Storage.Pickers.FolderPicker();
folderPicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary;
folderPicker.FileTypeFilter.Add("*");
Windows.Storage.StorageFolder subFolder = await folderPicker.PickSingleFolderAsync();
//KnownFolders.DocumentsLibrary
//StorageFolder Myfolder = KnownFolders.DocumentsLibrary;
//StorageFolder subFolder = await Myfolder.GetFolderAsync("YouSubFolder");
List<string> fileTypeFilter = new List<string>();
fileTypeFilter.Add(".txt");
QueryOptions queryOptions = new QueryOptions(Windows.Storage.Search.CommonFileQuery.OrderByName, fileTypeFilter);
StorageFileQueryResult queryResult = subFolder.CreateFileQueryWithOptions(queryOptions);
var files = await queryResult.GetFilesAsync();
foreach (var file in files)
{
string name = file.Name;
}
|
List all files in Documents Folder
Date : March 29 2020, 07:55 AM
|