iPhone Documents directory and UIFileSharingEnabled, hiding certain documents

The answer given by FrenchKiss Dev is not correct. The user will still be able to see the “.data” directory in iTunes and save that locally with all the files inside it. Instead, store private documents in Library/Preferences According to Apple: In addition to the directories documented previously, the entire /Library directory has always been … Read more

Print Directory & File Structure with icons for representation in Markdown [closed]

I followed an example in another repository and wrapped the directory structure within a pair of triple backticks (“`): “` project │ README.md │ file001.txt │ └───folder1 │ │ file011.txt │ │ file012.txt │ │ │ └───subfolder1 │ │ file111.txt │ │ file112.txt │ │ … │ └───folder2 │ file021.txt │ file022.txt “`

Travel directory tree with limited recursion depth

I think the easiest and most stable approach would be to copy the functionality of os.walk straight out of the source and insert your own depth-controlling parameter. import os import os.path as path def walk(top, topdown=True, onerror=None, followlinks=False, maxdepth=None): islink, join, isdir = path.islink, path.join, path.isdir try: names = os.listdir(top) except OSError, err: if onerror … Read more

How to get only images using scandir in PHP?

You can use glob $images = glob(‘/tmp/*.{jpeg,gif,png}’, GLOB_BRACE); If you need this to be case-insensitive, you could use a DirectoryIterator in combination with a RegexIterator or pass the result of scandir to array_map and use a callback that filters any unwanted extensions. Whether you use strpos, fnmatch or pathinfo to get the extension is up … Read more

Populate TreeView with file system directory structure

Option #1: Recursive approach: private void ListDirectory(TreeView treeView, string path) { treeView.Nodes.Clear(); var rootDirectoryInfo = new DirectoryInfo(path); treeView.Nodes.Add(CreateDirectoryNode(rootDirectoryInfo)); } private static TreeNode CreateDirectoryNode(DirectoryInfo directoryInfo) { var directoryNode = new TreeNode(directoryInfo.Name); foreach (var directory in directoryInfo.GetDirectories()) directoryNode.Nodes.Add(CreateDirectoryNode(directory)); foreach (var file in directoryInfo.GetFiles()) directoryNode.Nodes.Add(new TreeNode(file.Name)); return directoryNode; } Option #2: Non-recursive approach: private static void ListDirectory(TreeView treeView, … Read more

Listing directory contents using C and Windows

Just like everyone else said (with FindFirstFile, FindNextFile and FindClose)… but with recursion! bool ListDirectoryContents(const char *sDir) { WIN32_FIND_DATA fdFile; HANDLE hFind = NULL; char sPath[2048]; //Specify a file mask. *.* = We want everything! sprintf(sPath, “%s\\*.*”, sDir); if((hFind = FindFirstFile(sPath, &fdFile)) == INVALID_HANDLE_VALUE) { printf(“Path not found: [%s]\n”, sDir); return false; } do { … Read more

List directory tree structure in python?

Here’s a function to do that with formatting: import os def list_files(startpath): for root, dirs, files in os.walk(startpath): level = root.replace(startpath, ”).count(os.sep) indent=” ” * 4 * (level) print(‘{}{}/’.format(indent, os.path.basename(root))) subindent=” ” * 4 * (level + 1) for f in files: print(‘{}{}’.format(subindent, f))