File.Exists()

  • Thread starter Thread starter repairman2003
  • Start date Start date
R

repairman2003

I'm trying to check whether a .lnk (LNK - Windows shortcut file)
exists. I can successfully create the lnk file and then go browse to
the folder and see the lnk file is there, but calling
File.Exists("test.lnk") fails. How can I do this?
 
I'm trying to check whether a .lnk (LNK - Windows shortcut file)
exists. I can successfully create the lnk file and then go browse to
the folder and see the lnk file is there, but calling
File.Exists("test.lnk") fails. How can I do this?

Have you tried specifying the fully qualified file path?


Mattias
 
Have you tried specifying the fully qualified file path?

Mattias

yeah. I used Directory.SetCurrentDirectory() to set the path so I
wouldn't have to type in the full path. But not running that and just
inserting the full path still results in the same failure.
 
use Path.Combine to create a absolute path

--
Sheng Jiang
Microsoft MVP in VC++
Have you tried specifying the fully qualified file path?

Mattias

yeah. I used Directory.SetCurrentDirectory() to set the path so I
wouldn't have to type in the full path. But not running that and just
inserting the full path still results in the same failure.
 
That's not the problem. The problem is the File.Exists() returns
false no matter what if it is a .lnk file. I even created one in c:\
and called File.Exists("c:\\test.lnk") and it still returns false.
 
Ok, after much headache, my boss found that windows hides the file
extension for .lnk files no matter what. So File.Exists("c:\
\test.lnk.lnk") returns true.
 
Back
Top