Click here to Skip to main content
15,922,166 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to save image in a folder? and how to show image in a picturebox with windows project by C# language Pin
Luc Pattyn25-Mar-09 3:14
sitebuilderLuc Pattyn25-Mar-09 3:14 
AnswerRe: How to save image in a folder? and how to show image in a picturebox with windows project by C# language Pin
Xmen Real 24-Mar-09 20:53
professional Xmen Real 24-Mar-09 20:53 
AnswerRe: How to save image in a folder? and how to show image in a picturebox with windows project by C# language Pin
0x3c024-Mar-09 21:05
0x3c024-Mar-09 21:05 
AnswerRe: How to save image in a folder? and how to show image in a picturebox with windows project by C# language Pin
Tom Deketelaere24-Mar-09 23:22
professionalTom Deketelaere24-Mar-09 23:22 
AnswerRe: How to save image in a folder? and how to show image in a picturebox with windows project by C# language Pin
Thomas Krojer25-Mar-09 2:45
Thomas Krojer25-Mar-09 2:45 
QuestionHow to attach a file(attachment) in a datagrid cell? Pin
hhill24-Mar-09 20:27
hhill24-Mar-09 20:27 
AnswerRe: How to attach a file(attachment) in a datagrid cell? Pin
King Julien24-Mar-09 21:37
King Julien24-Mar-09 21:37 
QuestionListView in C# Pin
mrithula824-Mar-09 20:00
mrithula824-Mar-09 20:00 
Hi I am using this code to list the files in ListView control.When i try to add the files to the listview control using
listView1.Items.Add(fil2.ToString());
it gives me only one file i.e the last file in the folder.What change should i do to list all the files in that folder?Please help me with this
amespace WindowsApplication30
{
    public partial class Form1 : Form
    {
        XmlTextReader reader;
        XmlDocument doc = new XmlDocument();
        ColumnHeader colHead;
        String sss = "";
        //private System.Windows.Forms.ListView lwFilesAndFolders;
        public Form1()
        {
            InitializeComponent();
        }

        private void ListDrives_Click(object sender, EventArgs e)
        {
            string[] drives = Environment.GetLogicalDrives();
            // Loop into the string array
            foreach (string strDrive in drives)
            {
                // Add items (drives) to the list
                listBox1.Items.Add(strDrive.ToString());
            }
        }

        private void ShowPath_Click(object sender, EventArgs e)
        {
            CreateHeadersAndFillListView();
            PaintList(sss);
        }

        private void CreateHeadersAndFillListView()
        {
            colHead = new ColumnHeader();
            colHead.Text = "Servers";
            colHead.Width = 200;
            listView1.Columns.Add(colHead);

            colHead = new ColumnHeader();
            colHead.Text = "Status";
            colHead.Width = 100;
            listView1.Columns.Add(colHead);

            colHead = new ColumnHeader();
            colHead.Text = "Last accessed";
            colHead.Width = 100;
            listView1.Columns.Add(colHead);            
        }

        private void PaintList(String sss)
        {
            try
            {
                //ListViewItem lvi;
                //ListViewItem.ListViewSubItem lvsi;
                reader = new XmlTextReader("path.xml");
               
                while (reader.Read())
                {
                    switch (reader.NodeType)
                    {
                        case XmlNodeType.Text: //Display the text in each element.
                            //   Console.WriteLine(reader.Value);
                            String s1;
                            s1 = reader.Value;
                            String ss;
                            ss = listBox1.SelectedItem.ToString();
                            sss = ss + s1;
                            object o3 = (object)sss;
                            //String s = (string)o3;
                            //listBox2.Items.Add(o3);

                            DirectoryInfo dire = new DirectoryInfo(sss);
                            if (dire.Exists)
                            {
                                String[] folder;
                                folder = Directory.GetDirectories(sss);
                                foreach (string foldername in folder)
                                {
                                    DirectoryInfo di = new DirectoryInfo(foldername);
                                    if (di.Exists)
                                    {
                                        String[] files;
                                        files = Directory.GetFiles(foldername);
                                        listView1.Items.Clear();

                                        //this.listView1.BeginUpdate();

                                        foreach (String filename in files)
                                        {
                                            FileInfo fil2 = new FileInfo(filename);
                                            listView1.Items.Add(fil2.ToString());
                                           
                //lvi = new ListViewItem(fil2.ToString());
               //   lvi = new ListViewItem(ssfil2);
              //    //lvi.Text = fil2.Name.ToString();
             //   listView1.Items.Add(lvi);
            //}
            //lvi.ImageIndex = 0;
                                            //lvi.Tag = fil2.FullName;

               //lvsi = new ListViewItem.ListViewSubItem();
                                            //lvsi.Text = "sub item";
                                            //lvi.SubItems.Add(lvsi);

                  //lvsi = new ListViewItem.ListViewSubItem();
                     //lvsi.Text = di.LastAccessTime.ToString();
                                            //lvi.SubItems.Add(lvsi);

                                            //this.listView1.Items.Add(lvi);
                                        }}}}
                                   break;}}
                 
               // this.listView1.EndUpdate();
            }
            catch (System.Exception err)
            {
                MessageBox.Show("Error: " + err.Message);
            }   }} }      

AnswerRe: ListView in C# Pin
Christian Graus24-Mar-09 20:25
protectorChristian Graus24-Mar-09 20:25 
GeneralRe: ListView in C# Pin
mrithula824-Mar-09 20:56
mrithula824-Mar-09 20:56 
GeneralRe: ListView in C# Pin
King Julien24-Mar-09 21:23
King Julien24-Mar-09 21:23 
GeneralRe: ListView in C# Pin
mrithula824-Mar-09 21:36
mrithula824-Mar-09 21:36 
GeneralRe: ListView in C# Pin
King Julien24-Mar-09 23:00
King Julien24-Mar-09 23:00 
GeneralRe: ListView in C# Pin
mrithula825-Mar-09 0:11
mrithula825-Mar-09 0:11 
GeneralRe: ListView in C# Pin
King Julien25-Mar-09 0:55
King Julien25-Mar-09 0:55 
GeneralRe: ListView in C# Pin
mrithula825-Mar-09 19:25
mrithula825-Mar-09 19:25 
GeneralRe: ListView in C# Pin
King Julien25-Mar-09 20:08
King Julien25-Mar-09 20:08 
GeneralRe: ListView in C# Pin
mrithula825-Mar-09 20:18
mrithula825-Mar-09 20:18 
GeneralRe: ListView in C# Pin
King Julien25-Mar-09 20:49
King Julien25-Mar-09 20:49 
GeneralRe: ListView in C# Pin
mrithula825-Mar-09 21:08
mrithula825-Mar-09 21:08 
GeneralRe: ListView in C# Pin
King Julien25-Mar-09 21:30
King Julien25-Mar-09 21:30 
GeneralRe: ListView in C# Pin
mrithula826-Mar-09 1:08
mrithula826-Mar-09 1:08 
GeneralRe: ListView in C# Pin
King Julien26-Mar-09 1:24
King Julien26-Mar-09 1:24 
GeneralRe: ListView in C# Pin
mrithula826-Mar-09 1:32
mrithula826-Mar-09 1:32 
GeneralRe: ListView in C# Pin
King Julien26-Mar-09 1:56
King Julien26-Mar-09 1:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.