Question

I am trying to check if file that i want to create is executable.

The check will be by given file path, for example:

c:\good.txt

I want to check if file is executable before I will create it.

I think to use this function:

with the SHGFI_USEFILEATTRIBUTES flag, but I can't use this flag with the SHGFI_EXETYPE flag.

It means that I can't use the SHGFI_EXETYPE flag on a non exiting file.

Is there any another way to check if file is executable before I create the file?

No correct solution

OTHER TIPS

A file that does not exist cannot be ether executable or non-executable. The executability of a file (or otherwise) is stored within its metadata, be that a filename, permission bits, attributes or whatever. A file that does not exist has none of those, and hence you cannot check for its executability.

You'll notice that the SHGetFileInfo function to which you refer is document thus:

Retrieves information about an object in the file system, such as a file, folder, directory, or drive root.

Note the bit about it retrieving information about an object in the file system (not 'an object not in the file system).

A file which doesn't exist is not executable. You're asking a question which doesn't make sense. 'How hot is the water in this empty glass?' - how can something which doesn't exist have a property?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top