Arvind Gurav

Arvind Gurav

  • NA
  • 20
  • 10.1k

copy path of currently selected files in windows explorer

Mar 29 2015 3:10 PM

 I created a right click shortcut entry (in Explorer's right click context menu) for my application, and I want to get the folder or file path on which right click is done?
 

my registry entry is
 
HKEY_CLASSES_ROOT\AllFilesystemObjects\shell\copy path2\command
where command = "C:\Users\Atrix\Desktop\ConsoleApplication1.exe";
 

my c# code....

string fileName = "myfile.ext";
string fullPath;
fullPath = Path.GetFullPath(fileName);
 
//and I m trying to save the path to txt file.

string log = fullPath;   
string filePath = @"C:\Users\Atrix\Desktop\log.txt";
            FileStream myLog = new FileStream(filePath,FileMode.Append ,FileAccess.Write);
            StreamWriter sw = new StreamWriter(myLog);
            sw.Write(log);
            sw.Close();
            myLog.Close();
            
 

 
when I right click on any file on desktop and select "copy path" option
then every time same data is saved in txt file
 
C:\Users\Atrix\Desktop\myfile.ext
 

I want the complete path of the selected file with the extension of file....
 
plz help me....