Reputation: 380
I am currently working at a C# FTP Client and I need some help.
The client connects to a FTP server, retrieves directories and displys their names into a ListView.
But I also want to display a small icon for those directories/files, something like in Windows Explorer. You know what I am talking about...
Can anyone help me? Thanks!
LE:
By now I have this method:
private void listFiles(String path)
{
connection = (FtpWebRequest)FtpWebRequest.Create(path);
connection.Method = WebRequestMethods.Ftp.ListDirectory;
WebResponse response = connection.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream());
string line = reader.ReadLine();
while (line != null)
{
listView1.Items.Add(new ListViewItem(line));
}
}
What should I add? I am new to c#...
Upvotes: 0
Views: 3480
Reputation: 40
If it's a wpf listview you can use the DataTemplate
<ListView>
<ListView.ItemTemplate>
<DataTemplate>
.. image and <TextBlock> binded to the property you want to show (probably the file name)
Upvotes: 0
Reputation: 33738
Download/find an appropriate icon, add an imagelist, add your icon to the imagelist, set the ListView.SmallImageList property to your imagelist, set the rows' .SmallIconIndex or .SmallIconImageKey (I think) to the index/key of the image in the imagelist.
Upvotes: 2