Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / November 2007

Tip: Looking for answers? Try searching our database.

File.Exists()

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
repairman2003@gmail.com - 16 Nov 2007 20:34 GMT
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?
Mattias Sjögren - 16 Nov 2007 21:20 GMT
>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

Signature

Mattias Sjögren [C# MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

repairman2003@gmail.com - 16 Nov 2007 21:38 GMT
On Nov 16, 4:20 pm, Mattias Sjögren <mattias.dont.want.s...@mvps.org>
wrote:
> >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
[quoted text clipped - 8 lines]
> Mattias Sjögren [C# MVP]  mattias @ mvps.orghttp://www.msjogren.net/dotnet/|http://www.dotnetinterop.com
> Please reply only to the newsgroup.

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.
Sheng Jiang[MVP] - 16 Nov 2007 22:13 GMT
use Path.Combine to create a absolute path

Signature

Sheng Jiang
Microsoft MVP in VC++

On Nov 16, 4:20 pm, Mattias Sjögren <mattias.dont.want.s...@mvps.org>
wrote:
> >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
[quoted text clipped - 8 lines]
> Mattias Sjögren [C# MVP]  mattias @ mvps.orghttp://www.msjogren.net/dotnet/|http://www.dotnetinterop.com
> Please reply only to the newsgroup.

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.
repairman2003@gmail.com - 19 Nov 2007 15:50 GMT
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.
repairman2003@gmail.com - 19 Nov 2007 16:01 GMT
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.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.