示例#1
0
        /// <include file='doc\FileDialog.uex' path='docs/doc[@for="FileDialog.GetMultiselectFiles"]/*' />
        /// <devdoc>
        ///     Extracts the filename(s) returned by the file dialog.
        /// </devdoc>
        private string[] GetMultiselectFiles(CharBuffer charBuffer)
        {
            string directory = charBuffer.GetString();
            string fileName  = charBuffer.GetString();

            if (fileName.Length == 0)
            {
                return new string[] {
                           directory
                }
            }
            ;
            if (directory[directory.Length - 1] != '\\')
            {
                directory = directory + "\\";
            }
            ArrayList names = new ArrayList();

            do
            {
                if (fileName[0] != '\\' && (fileName.Length <= 3 ||
                                            fileName[1] != ':' || fileName[2] != '\\'))
                {
                    fileName = directory + fileName;
                }
                names.Add(fileName);
                fileName = charBuffer.GetString();
            } while (fileName.Length > 0);
            string[] temp = new string[names.Count];
            names.CopyTo(temp, 0);
            return(temp);
        }
示例#2
0
        private string[] GetMultiselectFiles(System.Windows.Forms.UnsafeNativeMethods.CharBuffer charBuffer)
        {
            string str  = charBuffer.GetString();
            string str2 = charBuffer.GetString();

            if (str2.Length == 0)
            {
                return(new string[] { str });
            }
            if (str[str.Length - 1] != '\\')
            {
                str = str + @"\";
            }
            ArrayList list = new ArrayList();

            do
            {
                if ((str2[0] != '\\') && (((str2.Length <= 3) || (str2[1] != ':')) || (str2[2] != '\\')))
                {
                    str2 = str + str2;
                }
                list.Add(str2);
                str2 = charBuffer.GetString();
            }while (str2.Length > 0);
            string[] array = new string[list.Count];
            list.CopyTo(array, 0);
            return(array);
        }
示例#3
0
 private bool RunDialogOld(IntPtr hWndOwner)
 {
     NativeMethods.WndProc        hookProcPtr = new NativeMethods.WndProc(this.HookProc);
     NativeMethods.OPENFILENAME_I ofn         = new NativeMethods.OPENFILENAME_I();
     try {
         charBuffer = CharBuffer.CreateBuffer(FILEBUFSIZE);
         if (fileNames != null)
         {
             charBuffer.PutString(fileNames[0]);
         }
         ofn.lStructSize = Marshal.SizeOf(typeof(NativeMethods.OPENFILENAME_I));
         // Degrade to the older style dialog if we're not on Win2K.
         // We do this by setting the struct size to a different value
         //
         if (Environment.OSVersion.Platform != System.PlatformID.Win32NT ||
             Environment.OSVersion.Version.Major < 5)
         {
             ofn.lStructSize = 0x4C;
         }
         ofn.hwndOwner       = hWndOwner;
         ofn.hInstance       = Instance;
         ofn.lpstrFilter     = MakeFilterString(filter, this.DereferenceLinks);
         ofn.nFilterIndex    = filterIndex;
         ofn.lpstrFile       = charBuffer.AllocCoTaskMem();
         ofn.nMaxFile        = FILEBUFSIZE;
         ofn.lpstrInitialDir = initialDir;
         ofn.lpstrTitle      = title;
         ofn.Flags           = Options | (NativeMethods.OFN_EXPLORER | NativeMethods.OFN_ENABLEHOOK | NativeMethods.OFN_ENABLESIZING);
         ofn.lpfnHook        = hookProcPtr;
         ofn.FlagsEx         = NativeMethods.OFN_USESHELLITEM;
         if (defaultExt != null && AddExtension)
         {
             ofn.lpstrDefExt = defaultExt;
         }
         //Security checks happen here
         return(RunFileDialog(ofn));
     }
     finally {
         charBuffer = null;
         if (ofn.lpstrFile != IntPtr.Zero)
         {
             Marshal.FreeCoTaskMem(ofn.lpstrFile);
         }
     }
 }
示例#4
0
        private bool RunDialogOld(IntPtr hWndOwner)
        {
            bool flag;

            System.Windows.Forms.NativeMethods.WndProc        proc = new System.Windows.Forms.NativeMethods.WndProc(this.HookProc);
            System.Windows.Forms.NativeMethods.OPENFILENAME_I ofn  = new System.Windows.Forms.NativeMethods.OPENFILENAME_I();
            try
            {
                this.charBuffer = System.Windows.Forms.UnsafeNativeMethods.CharBuffer.CreateBuffer(0x2000);
                if (this.fileNames != null)
                {
                    this.charBuffer.PutString(this.fileNames[0]);
                }
                ofn.lStructSize = Marshal.SizeOf(typeof(System.Windows.Forms.NativeMethods.OPENFILENAME_I));
                if ((Environment.OSVersion.Platform != PlatformID.Win32NT) || (Environment.OSVersion.Version.Major < 5))
                {
                    ofn.lStructSize = 0x4c;
                }
                ofn.hwndOwner       = hWndOwner;
                ofn.hInstance       = this.Instance;
                ofn.lpstrFilter     = MakeFilterString(this.filter, this.DereferenceLinks);
                ofn.nFilterIndex    = this.filterIndex;
                ofn.lpstrFile       = this.charBuffer.AllocCoTaskMem();
                ofn.nMaxFile        = 0x2000;
                ofn.lpstrInitialDir = this.initialDir;
                ofn.lpstrTitle      = this.title;
                ofn.Flags           = this.Options | 0x880020;
                ofn.lpfnHook        = proc;
                ofn.FlagsEx         = 0x1000000;
                if ((this.defaultExt != null) && this.AddExtension)
                {
                    ofn.lpstrDefExt = this.defaultExt;
                }
                flag = this.RunFileDialog(ofn);
            }
            finally
            {
                this.charBuffer = null;
                if (ofn.lpstrFile != IntPtr.Zero)
                {
                    Marshal.FreeCoTaskMem(ofn.lpstrFile);
                }
            }
            return(flag);
        }
示例#5
0
        protected override IntPtr HookProc(IntPtr hWnd, int msg, IntPtr wparam, IntPtr lparam)
        {
            if (msg == NativeMethods.WM_NOTIFY)
            {
                dialogHWnd = UnsafeNativeMethods.GetParent(new HandleRef(null, hWnd));
                try {
                    UnsafeNativeMethods.OFNOTIFY notify = (UnsafeNativeMethods.OFNOTIFY)UnsafeNativeMethods.PtrToStructure(lparam, typeof(UnsafeNativeMethods.OFNOTIFY));

                    switch (notify.hdr_code)
                    {
                    case -601:     /* CDN_INITDONE */
                        MoveToScreenCenter(dialogHWnd);
                        break;

                    case -602:     /* CDN_SELCHANGE */
                        NativeMethods.OPENFILENAME_I ofn = (NativeMethods.OPENFILENAME_I)UnsafeNativeMethods.PtrToStructure(notify.lpOFN, typeof(NativeMethods.OPENFILENAME_I));
                        // Get the buffer size required to store the selected file names.
                        int sizeNeeded = (int)UnsafeNativeMethods.SendMessage(new HandleRef(this, dialogHWnd), 1124 /*CDM_GETSPEC*/, System.IntPtr.Zero, System.IntPtr.Zero);
                        if (sizeNeeded > ofn.nMaxFile)
                        {
                            // A bigger buffer is required.
                            try {
                                int newBufferSize = sizeNeeded + (FILEBUFSIZE / 4);
                                // Allocate new buffer
                                CharBuffer charBufferTmp = CharBuffer.CreateBuffer(newBufferSize);
                                IntPtr     newBuffer     = charBufferTmp.AllocCoTaskMem();
                                // Free old buffer
                                Marshal.FreeCoTaskMem(ofn.lpstrFile);
                                // Substitute buffer
                                ofn.lpstrFile   = newBuffer;
                                ofn.nMaxFile    = newBufferSize;
                                this.charBuffer = charBufferTmp;
                                Marshal.StructureToPtr(ofn, notify.lpOFN, true);
                                Marshal.StructureToPtr(notify, lparam, true);
                            }
                            catch {
                                // intentionaly not throwing here.
                            }
                        }
                        this.ignoreSecondFileOkNotification = false;
                        break;

                    case -604:     /* CDN_SHAREVIOLATION */
                        // See VS Whidbey 95342. When the selected file is locked for writing,
                        // we get this notification followed by *two* CDN_FILEOK notifications.
                        this.ignoreSecondFileOkNotification = true;      // We want to ignore the second CDN_FILEOK
                        this.okNotificationCount            = 0;         // to avoid a second prompt by PromptFileOverwrite.
                        break;

                    case -606:     /* CDN_FILEOK */
                        if (this.ignoreSecondFileOkNotification)
                        {
                            // We got a CDN_SHAREVIOLATION notification and want to ignore the second CDN_FILEOK notification
                            if (this.okNotificationCount == 0)
                            {
                                this.okNotificationCount = 1;       // This one is the first and is all right.
                            }
                            else
                            {
                                // This is the second CDN_FILEOK, so we want to ignore it.
                                this.ignoreSecondFileOkNotification = false;
                                UnsafeNativeMethods.SetWindowLong(new HandleRef(null, hWnd), 0, new HandleRef(null, NativeMethods.InvalidIntPtr));
                                return(NativeMethods.InvalidIntPtr);
                            }
                        }
                        if (!DoFileOk(notify.lpOFN))
                        {
                            UnsafeNativeMethods.SetWindowLong(new HandleRef(null, hWnd), 0, new HandleRef(null, NativeMethods.InvalidIntPtr));
                            return(NativeMethods.InvalidIntPtr);
                        }
                        break;
                    }
                }
                catch {
                    if (dialogHWnd != IntPtr.Zero)
                    {
                        UnsafeNativeMethods.EndDialog(new HandleRef(this, dialogHWnd), IntPtr.Zero);
                    }
                    throw;
                }
            }
            return(IntPtr.Zero);
        }
 private bool RunDialogOld(IntPtr hWndOwner)
 {
     bool flag;
     System.Windows.Forms.NativeMethods.WndProc proc = new System.Windows.Forms.NativeMethods.WndProc(this.HookProc);
     System.Windows.Forms.NativeMethods.OPENFILENAME_I ofn = new System.Windows.Forms.NativeMethods.OPENFILENAME_I();
     try
     {
         this.charBuffer = System.Windows.Forms.UnsafeNativeMethods.CharBuffer.CreateBuffer(0x2000);
         if (this.fileNames != null)
         {
             this.charBuffer.PutString(this.fileNames[0]);
         }
         ofn.lStructSize = Marshal.SizeOf(typeof(System.Windows.Forms.NativeMethods.OPENFILENAME_I));
         if ((Environment.OSVersion.Platform != PlatformID.Win32NT) || (Environment.OSVersion.Version.Major < 5))
         {
             ofn.lStructSize = 0x4c;
         }
         ofn.hwndOwner = hWndOwner;
         ofn.hInstance = this.Instance;
         ofn.lpstrFilter = MakeFilterString(this.filter, this.DereferenceLinks);
         ofn.nFilterIndex = this.filterIndex;
         ofn.lpstrFile = this.charBuffer.AllocCoTaskMem();
         ofn.nMaxFile = 0x2000;
         ofn.lpstrInitialDir = this.initialDir;
         ofn.lpstrTitle = this.title;
         ofn.Flags = this.Options | 0x880020;
         ofn.lpfnHook = proc;
         ofn.FlagsEx = 0x1000000;
         if ((this.defaultExt != null) && this.AddExtension)
         {
             ofn.lpstrDefExt = this.defaultExt;
         }
         flag = this.RunFileDialog(ofn);
     }
     finally
     {
         this.charBuffer = null;
         if (ofn.lpstrFile != IntPtr.Zero)
         {
             Marshal.FreeCoTaskMem(ofn.lpstrFile);
         }
     }
     return flag;
 }
        protected override IntPtr HookProc(IntPtr hWnd, int msg, IntPtr wparam, IntPtr lparam)
        {
            if (msg == 0x4e)
            {
                this.dialogHWnd = System.Windows.Forms.UnsafeNativeMethods.GetParent(new HandleRef(null, hWnd));
                try
                {
                    System.Windows.Forms.UnsafeNativeMethods.OFNOTIFY structure = (System.Windows.Forms.UnsafeNativeMethods.OFNOTIFY) System.Windows.Forms.UnsafeNativeMethods.PtrToStructure(lparam, typeof(System.Windows.Forms.UnsafeNativeMethods.OFNOTIFY));
                    switch (structure.hdr_code)
                    {
                        case -606:
                            if (this.ignoreSecondFileOkNotification)
                            {
                                if (this.okNotificationCount != 0)
                                {
                                    break;
                                }
                                this.okNotificationCount = 1;
                            }
                            goto Label_0171;

                        case -604:
                            this.ignoreSecondFileOkNotification = true;
                            this.okNotificationCount = 0;
                            goto Label_01CF;

                        case -602:
                        {
                            System.Windows.Forms.NativeMethods.OPENFILENAME_I openfilename_i = (System.Windows.Forms.NativeMethods.OPENFILENAME_I) System.Windows.Forms.UnsafeNativeMethods.PtrToStructure(structure.lpOFN, typeof(System.Windows.Forms.NativeMethods.OPENFILENAME_I));
                            int num = (int) System.Windows.Forms.UnsafeNativeMethods.SendMessage(new HandleRef(this, this.dialogHWnd), 0x464, IntPtr.Zero, IntPtr.Zero);
                            if (num > openfilename_i.nMaxFile)
                            {
                                try
                                {
                                    int size = num + 0x800;
                                    System.Windows.Forms.UnsafeNativeMethods.CharBuffer buffer = System.Windows.Forms.UnsafeNativeMethods.CharBuffer.CreateBuffer(size);
                                    IntPtr ptr = buffer.AllocCoTaskMem();
                                    Marshal.FreeCoTaskMem(openfilename_i.lpstrFile);
                                    openfilename_i.lpstrFile = ptr;
                                    openfilename_i.nMaxFile = size;
                                    this.charBuffer = buffer;
                                    Marshal.StructureToPtr(openfilename_i, structure.lpOFN, true);
                                    Marshal.StructureToPtr(structure, lparam, true);
                                }
                                catch
                                {
                                }
                            }
                            this.ignoreSecondFileOkNotification = false;
                            goto Label_01CF;
                        }
                        case -601:
                            CommonDialog.MoveToScreenCenter(this.dialogHWnd);
                            goto Label_01CF;

                        default:
                            goto Label_01CF;
                    }
                    this.ignoreSecondFileOkNotification = false;
                    System.Windows.Forms.UnsafeNativeMethods.SetWindowLong(new HandleRef(null, hWnd), 0, new HandleRef(null, System.Windows.Forms.NativeMethods.InvalidIntPtr));
                    return System.Windows.Forms.NativeMethods.InvalidIntPtr;
                Label_0171:
                    if (!this.DoFileOk(structure.lpOFN))
                    {
                        System.Windows.Forms.UnsafeNativeMethods.SetWindowLong(new HandleRef(null, hWnd), 0, new HandleRef(null, System.Windows.Forms.NativeMethods.InvalidIntPtr));
                        return System.Windows.Forms.NativeMethods.InvalidIntPtr;
                    }
                }
                catch
                {
                    if (this.dialogHWnd != IntPtr.Zero)
                    {
                        System.Windows.Forms.UnsafeNativeMethods.EndDialog(new HandleRef(this, this.dialogHWnd), IntPtr.Zero);
                    }
                    throw;
                }
            }
        Label_01CF:
            return IntPtr.Zero;
        }
示例#8
0
        protected override IntPtr HookProc(IntPtr hWnd, int msg, IntPtr wparam, IntPtr lparam)
        {
            if (msg == 0x4e)
            {
                this.dialogHWnd = System.Windows.Forms.UnsafeNativeMethods.GetParent(new HandleRef(null, hWnd));
                try
                {
                    System.Windows.Forms.UnsafeNativeMethods.OFNOTIFY structure = (System.Windows.Forms.UnsafeNativeMethods.OFNOTIFY)System.Windows.Forms.UnsafeNativeMethods.PtrToStructure(lparam, typeof(System.Windows.Forms.UnsafeNativeMethods.OFNOTIFY));
                    switch (structure.hdr_code)
                    {
                    case -606:
                        if (this.ignoreSecondFileOkNotification)
                        {
                            if (this.okNotificationCount != 0)
                            {
                                break;
                            }
                            this.okNotificationCount = 1;
                        }
                        goto Label_0171;

                    case -604:
                        this.ignoreSecondFileOkNotification = true;
                        this.okNotificationCount            = 0;
                        goto Label_01CF;

                    case -602:
                    {
                        System.Windows.Forms.NativeMethods.OPENFILENAME_I openfilename_i = (System.Windows.Forms.NativeMethods.OPENFILENAME_I)System.Windows.Forms.UnsafeNativeMethods.PtrToStructure(structure.lpOFN, typeof(System.Windows.Forms.NativeMethods.OPENFILENAME_I));
                        int num = (int)System.Windows.Forms.UnsafeNativeMethods.SendMessage(new HandleRef(this, this.dialogHWnd), 0x464, IntPtr.Zero, IntPtr.Zero);
                        if (num > openfilename_i.nMaxFile)
                        {
                            try
                            {
                                int size = num + 0x800;
                                System.Windows.Forms.UnsafeNativeMethods.CharBuffer buffer = System.Windows.Forms.UnsafeNativeMethods.CharBuffer.CreateBuffer(size);
                                IntPtr ptr = buffer.AllocCoTaskMem();
                                Marshal.FreeCoTaskMem(openfilename_i.lpstrFile);
                                openfilename_i.lpstrFile = ptr;
                                openfilename_i.nMaxFile  = size;
                                this.charBuffer          = buffer;
                                Marshal.StructureToPtr(openfilename_i, structure.lpOFN, true);
                                Marshal.StructureToPtr(structure, lparam, true);
                            }
                            catch
                            {
                            }
                        }
                        this.ignoreSecondFileOkNotification = false;
                        goto Label_01CF;
                    }

                    case -601:
                        CommonDialog.MoveToScreenCenter(this.dialogHWnd);
                        goto Label_01CF;

                    default:
                        goto Label_01CF;
                    }
                    this.ignoreSecondFileOkNotification = false;
                    System.Windows.Forms.UnsafeNativeMethods.SetWindowLong(new HandleRef(null, hWnd), 0, new HandleRef(null, System.Windows.Forms.NativeMethods.InvalidIntPtr));
                    return(System.Windows.Forms.NativeMethods.InvalidIntPtr);

Label_0171:
                    if (!this.DoFileOk(structure.lpOFN))
                    {
                        System.Windows.Forms.UnsafeNativeMethods.SetWindowLong(new HandleRef(null, hWnd), 0, new HandleRef(null, System.Windows.Forms.NativeMethods.InvalidIntPtr));
                        return(System.Windows.Forms.NativeMethods.InvalidIntPtr);
                    }
                }
                catch
                {
                    if (this.dialogHWnd != IntPtr.Zero)
                    {
                        System.Windows.Forms.UnsafeNativeMethods.EndDialog(new HandleRef(this, this.dialogHWnd), IntPtr.Zero);
                    }
                    throw;
                }
            }
Label_01CF:
            return(IntPtr.Zero);
        }
示例#9
0
 private bool RunDialogOld(IntPtr hWndOwner)
 {
     NativeMethods.WndProc hookProcPtr = new NativeMethods.WndProc(this.HookProc);
     NativeMethods.OPENFILENAME_I ofn = new NativeMethods.OPENFILENAME_I();
     try {
         charBuffer = CharBuffer.CreateBuffer(FILEBUFSIZE);
         if (fileNames != null) {
             charBuffer.PutString(fileNames[0]);
         }
         ofn.lStructSize = Marshal.SizeOf(typeof(NativeMethods.OPENFILENAME_I));
         // Degrade to the older style dialog if we're not on Win2K.
         // We do this by setting the struct size to a different value
         //
         if (Environment.OSVersion.Platform != System.PlatformID.Win32NT ||
             Environment.OSVersion.Version.Major < 5) {
             ofn.lStructSize = 0x4C;
         }
         ofn.hwndOwner = hWndOwner;
         ofn.hInstance = Instance;
         ofn.lpstrFilter = MakeFilterString(filter, this.DereferenceLinks);
         ofn.nFilterIndex = filterIndex;
         ofn.lpstrFile = charBuffer.AllocCoTaskMem();
         ofn.nMaxFile = FILEBUFSIZE;
         ofn.lpstrInitialDir = initialDir;
         ofn.lpstrTitle = title;
         ofn.Flags = Options | (NativeMethods.OFN_EXPLORER | NativeMethods.OFN_ENABLEHOOK | NativeMethods.OFN_ENABLESIZING);
         ofn.lpfnHook = hookProcPtr;
         ofn.FlagsEx = NativeMethods.OFN_USESHELLITEM;
         if (defaultExt != null && AddExtension) {
             ofn.lpstrDefExt = defaultExt;
         }
         //Security checks happen here
         return RunFileDialog(ofn);
     }
     finally {
         charBuffer = null;
         if (ofn.lpstrFile != IntPtr.Zero) {
             Marshal.FreeCoTaskMem(ofn.lpstrFile);
         }
     }
 }
示例#10
0
        protected override IntPtr HookProc(IntPtr hWnd, int msg, IntPtr wparam, IntPtr lparam) {
            if (msg == NativeMethods.WM_NOTIFY) {
                dialogHWnd = UnsafeNativeMethods.GetParent(new HandleRef(null, hWnd));
                try {
                    UnsafeNativeMethods.OFNOTIFY notify = (UnsafeNativeMethods.OFNOTIFY)UnsafeNativeMethods.PtrToStructure(lparam, typeof(UnsafeNativeMethods.OFNOTIFY));

                    switch (notify.hdr_code) {
                        case -601: /* CDN_INITDONE */
                            MoveToScreenCenter(dialogHWnd);
                            break;
                        case -602: /* CDN_SELCHANGE */
                            NativeMethods.OPENFILENAME_I ofn = (NativeMethods.OPENFILENAME_I)UnsafeNativeMethods.PtrToStructure(notify.lpOFN, typeof(NativeMethods.OPENFILENAME_I));
                            // Get the buffer size required to store the selected file names.
                            int sizeNeeded = (int)UnsafeNativeMethods.SendMessage(new HandleRef(this, dialogHWnd), 1124 /*CDM_GETSPEC*/, System.IntPtr.Zero, System.IntPtr.Zero);
                            if (sizeNeeded > ofn.nMaxFile) {
                                // A bigger buffer is required.
                                try {
                                    int newBufferSize = sizeNeeded + (FILEBUFSIZE / 4);
                                    // Allocate new buffer
                                    CharBuffer charBufferTmp = CharBuffer.CreateBuffer(newBufferSize);
                                    IntPtr newBuffer = charBufferTmp.AllocCoTaskMem();
                                    // Free old buffer
                                    Marshal.FreeCoTaskMem(ofn.lpstrFile);
                                    // Substitute buffer
                                    ofn.lpstrFile = newBuffer;
                                    ofn.nMaxFile = newBufferSize;
                                    this.charBuffer = charBufferTmp;
                                    Marshal.StructureToPtr(ofn, notify.lpOFN, true);
                                    Marshal.StructureToPtr(notify, lparam, true);
                                }
                                catch {
                                    // intentionaly not throwing here.
                                }
                            }
                            this.ignoreSecondFileOkNotification = false;
                            break;
                        case -604: /* CDN_SHAREVIOLATION */
                            // See VS Whidbey 95342. When the selected file is locked for writing,
                            // we get this notification followed by *two* CDN_FILEOK notifications.                            
                            this.ignoreSecondFileOkNotification = true;  // We want to ignore the second CDN_FILEOK
                            this.okNotificationCount = 0;                // to avoid a second prompt by PromptFileOverwrite.
                            break;
                        case -606: /* CDN_FILEOK */
                            if (this.ignoreSecondFileOkNotification)
                            {
                                // We got a CDN_SHAREVIOLATION notification and want to ignore the second CDN_FILEOK notification
                                if (this.okNotificationCount == 0)
                                {
                                    this.okNotificationCount = 1;   // This one is the first and is all right.
                                }
                                else
                                {
                                    // This is the second CDN_FILEOK, so we want to ignore it.
                                    this.ignoreSecondFileOkNotification = false;
                                    UnsafeNativeMethods.SetWindowLong(new HandleRef(null, hWnd), 0, new HandleRef(null, NativeMethods.InvalidIntPtr));
                                    return NativeMethods.InvalidIntPtr;
                                }
                            }
                            if (!DoFileOk(notify.lpOFN)) {
                                UnsafeNativeMethods.SetWindowLong(new HandleRef(null, hWnd), 0, new HandleRef(null, NativeMethods.InvalidIntPtr));
                                return NativeMethods.InvalidIntPtr;
                            }
                            break;
                    }
                }
                catch {
                    if (dialogHWnd != IntPtr.Zero) {
                        UnsafeNativeMethods.EndDialog(new HandleRef(this, dialogHWnd), IntPtr.Zero);
                    }
                    throw;
                }
            }
            return IntPtr.Zero;
        }
示例#11
0
 /// <include file='doc\FileDialog.uex' path='docs/doc[@for="FileDialog.GetMultiselectFiles"]/*' />
 /// <devdoc>
 ///     Extracts the filename(s) returned by the file dialog.
 /// </devdoc>
 private string[] GetMultiselectFiles(CharBuffer charBuffer) {
     string directory = charBuffer.GetString();
     string fileName = charBuffer.GetString();
     if (fileName.Length == 0) return new string[] {
             directory
         };
     if (directory[directory.Length - 1] != '\\') {
         directory = directory + "\\";
     }
     ArrayList names = new ArrayList();
     do {
         if (fileName[0] != '\\' && (fileName.Length <= 3 ||
                                     fileName[1] != ':' || fileName[2] != '\\')) {
             fileName = directory + fileName;
         }
         names.Add(fileName);
         fileName = charBuffer.GetString();
     } while (fileName.Length > 0);
     string[] temp = new string[names.Count];
     names.CopyTo(temp, 0);
     return temp;
 }