Hello again.
I have another problem =).
I need to change the 1.lnk "pointing" path, i can get it with the following code :

string path = @"c:\1.lnk";
            FileInfo fi = new FileInfo(@path);
            if (fi.FullName.EndsWith("lnk"))
                IWshShell shell = new WshShell();
                var lnk = shell.CreateShortcut(fi.FullName) as IWshShortcut;
                if (lnk != null)
                    textBox1.Text = lnk.FullName;

But when i try to do the next :

IWshShell shell = new WshShell();
                    FileInfo fi = new FileInfo(@fixme);
                    var lnk = shell.CreateShortcut(fi.FullName) as IWshShortcut;
                    lnk.FullName = "c:\1.exe";

The compiler gives me the next error : Property or indexer 'IWshRuntimeLibrary.IWshShortcut.FullName' cannot be assigned to -- it is read only .
So how can i write to it ?
Thanks in advance.

7 Years
Discussion Span
Last Post by devnull

If you want to change file name you need to use the


class, like this:

System.IO.File.Move(@"c:\1.lnk", @"c:\1.exe");

That is if you want to change and delete the old one, and if you want to keep both of the files use:

System.IO.File.Copy(@"c:\1.lnk", @"c:\1.exe", false);

The last parm that you send to the method ("false") it to not overwrite en old file, you can change it to true if you want to overwrite the old file!



I dont want to rename the file or copy it ,i want to change one of the properties of an .lnk file(windows shortcut format) . And the propertie is named FullName .


Yea i understood that, but you cant change this property as it read only, so you need to move or copy the file and then use it with the new name..!


Ok. Than gonna try searching on how to create a .lnk file . Thanks for the response any other ideia is wellcome.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.