close

 

filepath = new string[100];
            folderpath = "";
            totalframe = 0;
            using (var dialog = new FolderBrowserDialog())
{
                //setup here

                if (dialog.ShowDialog() == DialogResult.OK)  //check for OK...they might press cancel, so don't do anything if they did.
                {
                    folderpath = dialog.SelectedPath;
                    label1.Text = folderpath;
                    //do something with path
                }
            }
            DirectoryInfo d = new DirectoryInfo(@folderpath);//Assuming Test is your Folder
            FileInfo[] Files = d.GetFiles("*.tiff"); //Getting Text files
            string str = "";
            int findex = 0;
            foreach (FileInfo file in Files)
            {
                filepath[findex] = folderpath + "\\" + file.Name;
                findex++;
            }
            totalframe = findex;
            Image img = Image.FromFile(filepath[0]);
            pictureBox1.Image = img;


            /*
            using (OpenFileDialog dlg = new OpenFileDialog())
            {
                dlg.Title = "Open Image";
                dlg.Filter = "tiff files (*.tiff)|*.tiff";

                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    PictureBox PictureBox1 = new PictureBox();
                    filepath = dlg.FileName;
                    label1.Text = filepath;
                    Image i = Image.FromFile(filepath);
                    pictureBox1.Image = i;
                }
            }
            */

 

arrow
arrow
    全站熱搜

    KR 發表在 痞客邦 留言(0) 人氣()