-1

I have a .NET application which checks if a file exists in a Windows Shortcut. But the File.Exists method return false.

var filePath= @"E:\Reports\abc.pdf" //Where Reports is a windows shortcut to a Azure File Share
var isExists = File.Exists(filePath)
Console.WriteLine(isExists) //prints false

What did I try?

  • I verified that the account under which the program runs has access to shortcut and azure fileshare

What am i missing here?

PNDev
  • 530
  • 1
  • 4
  • 21

1 Answers1

1

You get false because this folder does not exist. What exists is a link file:

E:\Reports.lnk

So if you want to access the location first you need to determine the target of that shortcut.

lukbl
  • 1,703
  • 1
  • 7
  • 13