How do I use filesystem functions in PHP, using UTF-8 strings?

Just urlencode the string desired as a filename. All characters returned from urlencode are valid in filenames (NTFS/HFS/UNIX), then you can just urldecode the filenames back to UTF-8 (or whatever encoding they were in). Caveats (all apply to the solutions below as well): After url-encoding, the filename must be less that 255 characters (probably bytes). … Read more

How do I programmatically change file permissions?

Full control over file attributes is available in Java 7, as part of the “new” New IO facility (NIO.2). For example, POSIX permissions can be set on an existing file with setPosixFilePermissions(), or atomically at file creation with methods like createFile() or newByteChannel(). You can create a set of permissions using EnumSet.of(), but the helper … Read more

Can you call Directory.GetFiles() with multiple filters?

For .NET 4.0 and later, var files = Directory.EnumerateFiles(“C:\\path”, “*.*”, SearchOption.AllDirectories) .Where(s => s.EndsWith(“.mp3”) || s.EndsWith(“.jpg”)); For earlier versions of .NET, var files = Directory.GetFiles(“C:\\path”, “*.*”, SearchOption.AllDirectories) .Where(s => s.EndsWith(“.mp3”) || s.EndsWith(“.jpg”)); edit: Please read the comments. The improvement that Paul Farry suggests, and the memory/performance issue that Christian.K points out are both very important.

How many files can I put in a directory?

FAT32: Maximum number of files: 268,173,300 Maximum number of files per directory: 216 – 1 (65,535) Maximum file size: 2 GiB – 1 without LFS, 4 GiB – 1 with NTFS: Maximum number of files: 232 – 1 (4,294,967,295) Maximum file size Implementation: 244 – 26 bytes (16 TiB – 64 KiB) Theoretical: 264 – 26 bytes (16 EiB – 64 KiB) Maximum volume size Implementation: 232 – 1 clusters (256 TiB – 64 KiB) Theoretical: 264 – 1 clusters (1 YiB – 64 KiB) ext2: Maximum number of files: 1018 … Read more