Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I want to add images from folder and list it in dropdown . Like my application has folder name flags containing all the flags images and their country name. how do I add them to dropdown .

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
207 views
Welcome To Ask or Share your Answers For Others

1 Answer

Try using the System.IO.Directory.GetFiles and System.IO.Path.GetFileName

http://msdn.microsoft.com/en-us/library/system.io.directory.getfiles(v=vs.110).aspx

http://msdn.microsoft.com/en-us/library/system.io.path.getfilename(v=vs.110).aspx

Something like (haven't tried it)

// Process the list of files found in the directory. 
string [] files = Directory.GetFiles(yourDirectory);
foreach(string file in files) {
    string language = Path.GetFileName(file);
    ddlFlags.Items.Add(new ListItem(language, file));
}

Next time, improve your question by describing what you have tried so far, then it would be easier to help you.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...