public class photo
picture pbx =new picturebox();
private voide btnok(object sender, EventArgs e)
{
string[] files=System.IO.Directory.GetFiles(@"D:\Building_Case");
for each(string file in files)
{
pbx.image=image.fromfile(file);
}
pbx.DoubleClick+=pbx_DoubleClick;
}
void pbx_Double_Click(object sender, EventArgs e)
{
string path=pbx.imagelocation;
messagebox.show(path);
}
}
// path string always return null. so I don't know how to get picturebox file path to open with Windows Photo Viewer
plz help me. I am urgent
Loading

FroglegPosted Dec 4, 2013, 3:20 PM
2: You need to show images one at a time
3: You already have filename in array
public partial class Form1 : Form
{
PictureBox pbx;
string[] files;
int index = 0;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
loadPicboxFiles();
}
public void loadPicboxFiles()
{
pbx = new PictureBox();
pbx.Name = "pic1";
pbx.SizeMode = PictureBoxSizeMode.AutoSize;
pbx.Left = 10;
pbx.Top = 10;
pbx.DoubleClick += new EventHandler(pbx_DoubleClick);
this.Controls.Add(pbx);
files = Directory.GetFiles(@"D:\Building_Case");
}
private void button1_Click(object sender, EventArgs e)
{
if (checkFileIsImage(files[index]))
{
pbx.Image = Image.FromFile(files[index]);
textBox1.Text = files[index];
Application.DoEvents();
System.Threading.Thread.Sleep(2000);
}
index++;
}
public bool checkFileIsImage(string _file)
{
bool isImage = false;
string str = Path.GetExtension(_file);
if(str == ".jpg" |str ==".png"|str ==".bmp")
{
isImage = true;
}
return isImage;
}
private void pbx_DoubleClick(object sender, EventArgs e)
{
MessageBox.Show(files[index]);
}
}