Retrieving images with for loop [C#]
Go to solution
Solved by fizzlesticks,
It should work if you just move everything into the loop
string[] filePaths = Directory.GetFiles(@"C:\Users\Public\Pictures\Sample Pictures", "*.jpg", SearchOption.AllDirectories); foreach (string value in filePaths) { Image img = new Image(); BitmapImage bmpimg = new BitmapImage(); img.Width = 200; bmpimg.DecodePixelWidth = 200; img.Margin = new Thickness(5); bmpimg.BeginInit(); bmpimg.UriSource = new Uri(value); img.Source = bmpimg; wp_imgs.Children.Add(img); // <--- error here bmpimg.EndInit(); }
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now