parameters - C# ShortCut Path Modification -


i've created program generates shortcut specific exe selected via open file dialog, using library. got work want program add parameter target path make this: ("e:\cod4\iw3mp.exe" +seta map mp_crash). can add (+ seta map mp_crash) part after " mark without removing or ruining extension of .exe?

here block of code wrote add parameter:

label1.text = openfiledialog1.filename;  shortcut.targetpath = label1.text + " seta map mp_crash";  shortcut.save(); 

this code add seta part target ruin extension , "e:\cod4\iw3mp.exe seta map mp_crash "

please help. here full code :

using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.linq; using system.text; using system.windows.forms; using iwshruntimelibrary; using system.io;  namespace windowsformsapplication18  {     public partial class form1 : form      {           public form1()          {              initializecomponent(              );          }         public void createshortcut()         {              object shdesktop = (object)"desktop";             wshshell shell = new wshshell();             string shortcutaddress = (string)shell.specialfolders.item(ref shdesktop) + @"\server.lnk";             iwshshortcut shortcut = (iwshshortcut)shell.createshortcut(shortcutaddress);             shortcut.description = "server shortcut";             shortcut.hotkey = "ctrl+shift+n";             var ofd = new openfiledialog();             ofd.showdialog();             shortcut.targetpath = '"' + ofd.filename + '"' + "+seta map mp_crash";         }          private void button1_click(object sender, eventargs e)         {              createshortcut();         }          private void form1_load(object sender, eventargs e)         {           //  var ofd = new openfiledialog();          //   ofd.showdialog();         //    string shortcut = '"' + ofd.filename + '"' + "+seta map mp_crash";          //   openfiledialog1.defaultext = "exe";       //  / //  openfiledialog1.filename = "iw3mp.exe";          //  dialogresult result2 = openfiledialog1.showdialog();        //   label1.text = openfiledialog1.filename;        //   = label1.text;          //    if (result2 == dialogresult.ok)          //   {         //    }         }     } } 

based on updated question, try this

shortcut.targetpath = ofd.filename; shortcut.arguments = "seta map mp_crash"; 

Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -