Checking for a shortcut

1

I need to check the existence of a shortcut on the desktop of the computer, but the code below does not exit if (!File.Exists(pasta))

private void Instalando()
    {
        string pasta = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\estoque Box - Gerenciamento de estoque.Lnk";
        if (!File.Exists(pasta))
        {
            MessageBox.Show(pasta);
            pnInstalando.Visible = true;
            pnInstalando.Enabled = true;
        }
        else if (File.Exists(pasta))
        {
            MessageBox.Show("Olá");
            pbInstalando.Visible = false;
            pbInstalando.Enabled = false;
            pBarInstalando.Visible = false;
            pBarInstalando.Enabled = false;
            pbInstalado.Visible = true;
            btFechar.Enabled = true;
            btFechar.Visible = true;
        }
    }

The shortcut, even in the code it accuses the shortcut does not exist. Can anyone help me?

    
asked by anonymous 23.05.2017 / 20:20

1 answer

3

What's wrong is .Lnk in filename - this is duplicate.

Create the shortcut again by placing only "Inventory Stock". So Windows itself will create an .lnk.

Or rename the file and remove .Lnk .

That's enough to use:

"\estoque Box - Gerenciamento de estoque.lnk"
    
23.05.2017 / 20:38