For as far I know this no proper path:
string nonSystemDir = "C\\Downloads";
Shouldn't it be
string nonSystemDir = "C:\\Downloads";
or more readable
string nonSystemDir = @"C:\Downloads";
You could also add System.IO.Directory.Exists like so
private void urlShortcutToFolder(string linkName, string linkUrl)
{
//string deskDir = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
//using (StreamWriter writer = new StreamWriter(deskDir + "\\" + linkName + ".url"))
string nonSystemDir = @"C:\Downloads";
if(!System.IO.Directory.Exists(nonSystemDir))
{
throw New Exception("Path " + nonSystemDir + " is not valid");
}
using (StreamWriter writer = new StreamWriter(nonSystemDir + "\\" + linkName + ".url"))
{
writer.WriteLine("[InternetShortcut]");
writer.WriteLine("URL=" + linkUrl);
writer.Flush();
}
}