private void SetFileNameToSelectedItem(IntPtr hListView, IntPtr hFNCombo, int selectedIndex)
        {
            if (selectedIndex >= 0)
            {
                InteropUtil.LVITEM lvitem = new InteropUtil.LVITEM
                {
                    mask = InteropUtil.LVIF_TEXT
                };
                IntPtr nativeBuffer = Marshal.AllocCoTaskMem(InteropUtil.NumberOfFileChars * 2);
                for (int i = 0; i < InteropUtil.NumberOfFileChars; ++i)
                {
                    Marshal.WriteInt16(nativeBuffer, i * 2, '\0');
                }
                string name;

                try
                {
                    Marshal.WriteInt16(nativeBuffer, 0);
                    lvitem.pszText    = nativeBuffer;
                    lvitem.cchTextMax = InteropUtil.NumberOfFileChars;
                    uint length = hListView.SendListViewMessage(InteropUtil.LVM_GETITEMTEXT, (uint)selectedIndex, ref lvitem);
                    name = Marshal.PtrToStringUni(lvitem.pszText, (int)length);
                }
                finally
                {
                    Marshal.FreeCoTaskMem(nativeBuffer);
                }

                if (name != null && m_currentFolder != null)
                {
                    try
                    {
                        string path = System.IO.Path.Combine(m_currentFolder, name);
                        if (Directory.Exists(path))
                        {
                            hFNCombo.SetWindowTextW(name);
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
            }
        }
        private string GetFileNameFromSelectedItem(IntPtr hListView, int selectedIndex)
        {
            if (selectedIndex >= 0)
            {
                var lvitem = new InteropUtil.LVITEM();
                lvitem.mask = InteropUtil.LVIF_TEXT;
                IntPtr nativeBuffer = Marshal.AllocCoTaskMem(InteropUtil.NumberOfFileChars*2);
                for (int i = 0; i < InteropUtil.NumberOfFileChars; ++i)
                {
                    Marshal.WriteInt16(nativeBuffer, i*2, '\0');
                }
                string name;

                try
                {
                    Marshal.WriteInt16(nativeBuffer, 0);
                    lvitem.pszText = nativeBuffer;
                    lvitem.cchTextMax = InteropUtil.NumberOfFileChars;
                    uint length = InteropUtil.SendListViewMessageInt(hListView, InteropUtil.LVM_GETITEMTEXT,
                                                                     selectedIndex, ref lvitem);
                    name = Marshal.PtrToStringUni(lvitem.pszText, (int) length);
                }
                finally
                {
                    Marshal.FreeCoTaskMem(nativeBuffer);
                }

                if (name != null && m_currentFolder != null)
                {
                    try
                    {
                        string path = System.IO.Path.Combine(m_currentFolder, name);

                        return path;
                        if (Directory.Exists(path))
                        {
                            //hFNCombo.SetWindowTextW(name);
                        }
                    }
                    catch (Exception)
                    {
                    }
                }


                return name;
            }
            return string.Empty;
        }