Arianule
Arianule

Reputation: 9043

Retrieving the name of an image

This is a silly question perhaps but would like to know how to retrieve the name of an image.

for example

string name;
 Image imageOne = Image.FromFile("../../Images/PozeOne.jpg");
name = ?

Upvotes: 0

Views: 59

Answers (2)

neerajMAX
neerajMAX

Reputation: 269

    "PozeOne.jpg" is the name of image.... :-)

    string path="../../Images/PozeOne.jpg";
    string[] imageName=path.split('/');
    string image_Name_Is= imageName[imageName.Lenght-1];

Upvotes: 1

scartag
scartag

Reputation: 17680

You can use Path.GetFilename

var path  = "../../Images/PozeOne.jpg";

Image imageOne = Image.FromFile(path);

string name = Path.GetFilename(path);

Upvotes: 4

Related Questions