Note that there are some explanatory texts on larger screens.

plurals
  1. POC# ShortCut Path Modification
    text
    copied!<p>I've created a program which generates a shortcut to a specific EXE selected via the open file dialog, using some library. I got it to work but I want the program to add a parameter to the Target path to make it look like this: (<code>"E:\Cod4\iw3mp.exe" +Seta Map mp_crash</code>). What can I do to add the (<code>+ Seta Map mp_Crash</code>) part after the <code>"</code> mark without removing it or ruining the extension of the .exe? </p> <p>Here is block of the code I wrote to add the parameter: </p> <pre><code>label1.Text = openFileDialog1.FileName; shortcut.TargetPath = label1.Text + " Seta Map mp_crash"; shortcut.Save(); </code></pre> <p>This code will add the seta part to the target but it will ruin the extension and it will look like this <code>"E:\Cod4\iw3mp.exe Seta Map mp_crash "</code></p> <p>Please help. here is the full code :</p> <pre><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; // a = label1.Text; // if (result2 == DialogResult.OK) // { // } } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload