© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
22 replies
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
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));
    }
}
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."
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ operator * cannot be applied to operands of type T and T
C#CC# / help
3y ago
Cannot implicitly convert type 'System.Threading.Tasks.Task<string>' to 'string'
C#CC# / help
3y ago
Type cannot be found (CS7069) [Answered]
C#CC# / help
4y ago
✅ Convert from string to Type?
C#CC# / help
3y ago