C#C
C#3y ago
Hedreon

✅ Operator ! cannot be applied to type string

yeah I cannot really test this properly since Visual Studio is not available in my current operating system. Though, I am using an online compiler to debug this in some way, shape or form.

I haven't coded in C# in so long but I am contributing to an installer made in C# so how do I check if a special folder exists, and if not, add a different folder to the shortcutPaths?

if (FPM.Main.ShortcutStartMenu.Checked)
{
    if (!Environment.GetFolderPath(Environment.SpecialFolder.Programs))
    {
        shortcutPaths.Add(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu));
    }
    else
    {
        shortcutPaths.Add(Environment.GetFolderPath(Environment.SpecialFolder.Programs));
    }
}


I'm just so used to coding in Java that I use the ! operator when I mean something "isn't there."
Was this page helpful?