J
jennifereden.price
Hi,
I have the following function in a project that implements a shell
extension. This function shows all the files that the users has
selected and attempts to determine whether it is a directory or a file.
But, for some reason, it thinks that every file is a directory! I don't
understand the system aspect of the code - I only understand what it
formally does. Can anyone help me spot my error? Many thanks in
advance! Aaron Fude
public static void ShowSelected(uint m_hDrop) {
// if ( (uFlags & (uint)CMF.CMF_DEFAULTONLY) != 0) return;
uint nselected = DllImports.DragQueryFile(m_hDrop, 0xffffffff, null,
0);
for (uint s = 0; s < nselected; s++) {
StringBuilder sb = new StringBuilder(1024);
DllImports.DragQueryFile(m_hDrop, s, sb, sb.Capacity + 1);
string file = sb.ToString();
uint attr = DllImports.GetFileAttributes(file);
bool isdir = (attr & DllImports.FILE_ATTRIBUTE_DIRECTORY) != 0;
MessageBox.Show(((isdir)?"Directory: ":"File: ") + file + " " + attr
+ " " + isdir);
}
I have the following function in a project that implements a shell
extension. This function shows all the files that the users has
selected and attempts to determine whether it is a directory or a file.
But, for some reason, it thinks that every file is a directory! I don't
understand the system aspect of the code - I only understand what it
formally does. Can anyone help me spot my error? Many thanks in
advance! Aaron Fude
public static void ShowSelected(uint m_hDrop) {
// if ( (uFlags & (uint)CMF.CMF_DEFAULTONLY) != 0) return;
uint nselected = DllImports.DragQueryFile(m_hDrop, 0xffffffff, null,
0);
for (uint s = 0; s < nselected; s++) {
StringBuilder sb = new StringBuilder(1024);
DllImports.DragQueryFile(m_hDrop, s, sb, sb.Capacity + 1);
string file = sb.ToString();
uint attr = DllImports.GetFileAttributes(file);
bool isdir = (attr & DllImports.FILE_ATTRIBUTE_DIRECTORY) != 0;
MessageBox.Show(((isdir)?"Directory: ":"File: ") + file + " " + attr
+ " " + isdir);
}