-2

I have a drop down with list of doctors. What I would like to do is when you select on a name from the drop down list, to display a image.

The problem I am having is to search through the image folder and compare it with the name that was selected from the drop down.

Here is what I attempted to do below which does not work:

string imgPath = "\\AccessExpress\ASPCode\OCUpgrade52\images";

if(Directory.Exists(imgPath)){

    string Name = Parameter_SelectName;//Contains the selection from drop down

    if(File.Exists(Path.Combine(imgPath, Name)) )
        Response.Write("true");
    else
        Response.Write("false");
}
else
    Response.Write("false");

Getting the following error: CS1009: Unrecognized escape sequence

And having a hard time to grab the image that matches the selection to display

Update: I was able to resolve the issue with the following (I hope this helps others who are having similar issues):

Here is what i have so far:

string imgFolderPath = @"\\AccessExpress\ASPCode\OCUpgrade52\images";

bool folderExists = System.IO.Directory.Exists(imgFolderPath);

if(folderExists){
string urlPath = "http://oc2-reatest/OCUpgrade52/images/";
string imgName= Parameter_SelectName + ".png";
string img = string.Concat(urlPath,imgName);

bool fileExists = System.IO.File.Exists(System.IO.Path.Combine(imgFolderPath, imgName));

if(fileExists)
Response.Write("<img src='" + img + "' />");

else
Response.Write("File Does Not Exists");
}

else
Response.Write("Folder Does Not Exists");
Roberto Pegoraro
  • 1,313
  • 2
  • 16
  • 31
user9808783
  • 129
  • 11

1 Answers1

0

I think just a small change to your code would do it. Once you take the doctor's name from the comboBox or drop-down, I guess you're passing it directly to find whether the file exists or not.

Try this :-

            string Name = "Parameter_SelectName";
            string path = imgPath + Name + ".jpg"; //jpg being the extention of the pictures
            bool fileExists = System.IO.File.Exists(path);

I hope that'll do the trick.