0

I am developing a folder lock application which also has functionality of recovery.I have implemented a openFileDialog which opens the file explorer and when any file is deleted by user will be saved to my custom directory. how can i implement the functionality of copying the file to my custom directory when user press delete button from keyboard or from context menu my openFileDialog code is given below

  openFileDialog1.InitialDirectory = folderPath;
            if (RESOURCE.Equals("Images"))
            {
                openFileDialog1.Filter = "JPEG Files (*.jpeg)|*.jpeg|PNG Files (*.png)|*.png|GIF Files (*.gif)|*.gif";
            }

            openFileDialog1.FilterIndex = 2;
            openFileDialog1.RestoreDirectory = true;


            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    strfilename = openFileDialog1.InitialDirectory + openFileDialog1.FileName;
                    run();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
                }
            }
Imdad Haider
  • 5
  • 1
  • 7
  • 2
    This may help, I think you want to use a FileSystemWatcher and subscribe to the Renamed + Deleted events - http://stackoverflow.com/q/8048031/969613 – JMK Apr 07 '14 at 15:50
  • I do not know that FileSystemWatcher will work for me because i do not want to watch files event but to copy file to another directory when user clicks delete from any where i.e. delete from keyboard or using context menu – Imdad Haider Apr 08 '14 at 09:12

0 Answers0