title: c# how to copy the selectedItems (listview) into a variable then use it later (copy & paste) FileExplorer in ListView
body: <p>im making a file explorer tool in c# .. im using ListView to explore files</p>
  
  <p>but i have an issue when i copy items(files)</p>
  
  <pre><code>public ListView.SelectedListViewItemCollection copiedItems;
  
  private void btnCopy_Click(object sender, EventArgs e)
      {
          copiedItems = listView1.SelectedItems;
          infoLabel.Text = "Item(s) copied to clipboard.";
      }
  
  private void Paste()
      {
          if (copiedItems != null)
          {
              foreach (ListViewItem item in copiedItems)
              {
                  if (File.Exists(item.ToolTipText))
                  {
                      if (MessageBox.Show(item.ToolTipText + "is already exists\r\nDo you want to overwrite it?"
                      , "Overwrite", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk) == DialogResult.OK)
                      {
                          File.Copy(item.ToolTipText, currAddress, true);
                          infoLabel.Text = "Item(s) Pasted.";
                      }
                      return;
                  }
                  File.Copy(item.ToolTipText, currAddress, false);
                  infoLabel.Text = "Item(s) Pasted.";
              }
          }
      }
  </code></pre>
  
  <p>when i change the folder that i am into(currAddress)  .. the paste doesn't work because the</p>
  
  <pre><code> ListView.SelectedListViewItemCollection copiedItems 
  </code></pre>
  
  <p>changed to null. .. here's my explorer code</p>
  
  <pre><code>private void DirRecursive(string path)
      {
              DirectoryInfo dir = new DirectoryInfo(path);
              currAddress = path;
              txtAddress.Text = path;
              _iconListManager.ClearLists();
              listView1.Items.Clear();
              foreach (DirectoryInfo folder in dir.GetDirectories())
                  {
                      if ((folder.Attributes &amp; FileAttributes.Hidden) == FileAttributes.Hidden)
                          continue;
                      ListViewItem item = new ListViewItem();
                      item.Text = folder.Name;
                      item.Tag = (object)folder.Parent;
                      item.ToolTipText = folder.FullName;
                      item.ImageIndex = _iconListManager.AddFolderIcon(folder.FullName);
                      listView1.Items.Add(item);
                  }
                  foreach (FileInfo file in dir.GetFiles())
                  {
                      if ((file.Attributes &amp; FileAttributes.Hidden) == FileAttributes.Hidden)
                          continue;
                      ListViewItem item = new ListViewItem();
                      item.Text = file.Name;
                      item.Tag = (object)file.Directory.Parent;
                      item.ToolTipText = file.FullName;
                      item.ImageIndex = _iconListManager.AddFileIcon(file.FullName);
                      item.SubItems.Add(CnvrtUnit(file.Length));
                      listView1.Items.Add(item);
                  }
  </code></pre>
  
  <p>is there any explanation why copiedItems changed to null and how can i fix it ?</p>
  
  <p>thanks in advance :)</p>