Snippet. Vala. Getting Content Type of a FileThis Vala snippet shows how to get the content type of a file. File file = File.new_for_path("Hello_World.txt"); try { string file_content_type = file.query_info ("*", FileQueryInfoFlags.NONE).get_content_type(); stdout.printf ("Content type: %s\n", file_content_type); } catch (Error e) { stdout.printf("Error occurred"); } Result: Content type: txt/plain Updated on: 27 Dec 2024 |
|