Click here to Skip to main content
15,847,427 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
picUserimage.Source = new BitmapImage(new Uri(@"‪D:\images"));

What I have tried:

string text = @"file:\\\D:\images";
                        text = text.Replace(@"file:\\\", @"");
                        string userimagepath = AppDomain.CurrentDomain.BaseDirectory + text + ds.Tables[0].Rows[0][11].ToString();
                        if (!File.Exists(userimagepath))
                            picUserimage.Source = BitmapFromUri(new Uri(text));
Updated 17-Sep-22 20:25pm

1 solution

Because it isn't a valid path.

Look at your code: you start with
and your base directory is (say) the folder "C:\Test"You remove the "file:\\\" part:
Then you prefix the Base directory:
and what might be a file name (say "myfile.jpg") to get what you use as a URI:
Which isn't a valid path at all, and you seem surprised that the system picks up on that?
And then you ignore that and try to use the original folder all on it's own ...

Just like your previous (related) question, you need to think about exactly what you are trying to do and use the debugger to find out exactly what is happening in your code.

To be honest, 60 seconds with the debugger would have shown you exactly what was in text and useImagePath and you wouldn't have had to wait 18 hours for a response. I have to say that together with your previous question you do appear to be coding this using "guess and hope" instead of planning, and relying on others to fix it for you when it all fails.
That isn't a viable development technique going forward!
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900