用javascript做跳转
self.location.href="Message_board.jsp"

解决方案 »

  1.   

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using System.IO;
    using System.Runtime.InteropServices;
    using System.Collections;namespace Findfile2
    {
        public partial class Form1 : Form
        {        [DllImport("kernel32.dll", CharSet = CharSet.Auto)]
            static extern IntPtr FindFirstFile(string lpFileName, out WIN32_FIND_DATA lpFindFileData);        [DllImport("kernel32.dll", CharSet = CharSet.Auto)]
            static extern bool FindNextFile(IntPtr hFindFile, out WIN32_FIND_DATA lpFindFileData);        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
            struct WIN32_FIND_DATA
            {
                public FileAttributes dwFileAttributes;
                public FILETIME ftCreationTime;
                public FILETIME ftLastAccessTime;
                public FILETIME ftLastWriteTime;
                public uint nFileSizeHigh;
                public uint nFileSizeLow;
                public uint dwReserved0;
                public uint dwReserved1;
                [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
                public string cFileName;
                [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 14)]
                public string cAlternateFileName;
            }
            string strpath;
            string strcom;
            public Form1()
            {
                InitializeComponent();
            }        private void Form1_Load(object sender, EventArgs e)
            {        }        private void button2_Click(object sender, EventArgs e)
            {
                FolderBrowserDialog fb = new FolderBrowserDialog();
                fb.ShowDialog();
                strpath = fb.SelectedPath;
                // MessageBox.Show(strpath);
                
            }        private void button1_Click(object sender, EventArgs e)
            {
                strcom = comboBox1.Text;
                char[] chSplit = { '*' };
                string[] chext = strcom.Split(chSplit[0]);
                int chlength = chext.Length;
                listBox1.Items.Clear();
                findfile(strpath, chext[1]);        }        public void findfile(string path, string ext)
            {
                WIN32_FIND_DATA findData;
                string strTmp = "";
                string strA = "";
                strTmp += path + "\\*.*";
                strA += path + "\\*" + ext;
                IntPtr hFindHandle = FindFirstFile(strTmp, out findData);
                IntPtr ptr = new IntPtr(-1);
                ArrayList dirlist = new ArrayList();            if (hFindHandle != ptr)
                {
                    string AAAA = findData.dwFileAttributes.ToString();
                    if ("Directory" == AAAA && findData.cFileName != "." && findData.cFileName != "..")
                    {
                        dirlist.Add(findData.cFileName);
                       // listBox1.Items.Add(findData);
                    }                while (FindNextFile(hFindHandle, out findData))
                    {
                        AAAA = findData.dwFileAttributes.ToString();
                        if ("Directory" == AAAA && findData.cFileName != "." && findData.cFileName != "..")
                        {                        dirlist.Add(findData.cFileName);
                        }
                    }
                }//            hFindHandle = FindFirstFile(strA, out findData);
                if (hFindHandle != ptr)
                {
                    string AAAA = findData.dwFileAttributes.ToString();
                    if ("Directory" != AAAA)
                    {
                        listBox1.Items.Add(String.Format("{0}\\{1}", path, findData.cFileName));
                    }
                    else if ("Directory" == AAAA && findData.cFileName != "." && findData.cFileName != "..")
                    {
                        dirlist.Add(findData.cFileName);
                    }                while (FindNextFile(hFindHandle, out findData))
                    {
                        AAAA = findData.dwFileAttributes.ToString();
                        if ("Directory" != AAAA)
                        {                        listBox1.Items.Add(String.Format("{0}\\{1}", path, findData.cFileName));
                        }
                    }
                }            for (int i = 0; i < dirlist.Count; i++)
                {
                    string strSubPath = path + "\\" + dirlist[i].ToString();
                    findfile(strSubPath, ext);
                }          
            }
        }
    }