tan shen

tan shen

  • NA
  • 11
  • 1.7k

I want to make a simple picture slideshow from the stated fo

Nov 1 2017 10:15 PM
I want to make a simple picture slideshow from the stated folder. The label show the full location detail of the image, how can the label show the picture name only?
  1. int counter = 0;  
  2. private void button1_Click(object sender, EventArgs e)  
  3. {  
  4. timer1.Start(); //start the slideshow  
  5. }  
  6. private void timer1_Tick(object sender, EventArgs e)  
  7. {  
  8. counter++;  
  9. string path = @"C:\Users\Tan Wei Shen\Desktop\FYP\Animal";//directory of the picture  
  10. string[] filePaths = Directory.GetFiles(path, "*.jpg ");  
  11. if (counter > filePaths.Length - 1)  
  12. {  
  13. counter = 0; //reset the picture  
  14. }  
  15. pictureBox1.Image = Image.FromFile(filePaths[counter]); //show image  
  16. label1.Text = filePaths[counter]; //show name of the image  
  17. }

Answers (3)