System.IO.File.Exists

  • Thread starter Thread starter raibeart
  • Start date Start date
R

raibeart

I am trying to use System.IO.File.Exists to determine if a file exiusts
on a server. I am using a UNC path stored in a database table. Is
there a way to use UNC rather than a mapped drive?

For example:

\\Srv09\Data\LogCenter\Logs\log_1.tif will not work
x:\LogCenter\Logs\log_1.tif will work

Thanks in advance.

Robert
 
Really? File.Exists doesn't work on UNC paths? Oh well, I'm sure Dir(file)
still works on unc paths in VB.NET. Use that instead:

Dir("\\Srv09\Data\LogCenter\Logs\log_1.tif") <> ""
means the files doesn't exist.
 
I use File.IO.Exists against UNC all the time (Windows and/or Novell
servers).

No matter how impossibly sure you are the UNC path is correct, I would
double check to make sure it's correct. Maybe your WINS/DNS server has an
outdated address cached for Srv09, and it's sending your program a bogus
address... or the UNC is actually typo'd in the database but you assume it
isn't... or it's resolving to Srv09 on some other network somewhere else
that doesn't have that share on it, or you're running on Win98 and NETBIOS
isn't on, or "something stupid" like that. AFAIk, a valid UNC path should
work.
 
raibeart said:
I am trying to use System.IO.File.Exists to determine if a file exiusts
on a server. I am using a UNC path stored in a database table.

It's always worked for me, so ...

In what context are you executing this code?
Is it, for example, in a Windows Service, which well /not/ have access
to the network at all.

HTH,
Phill W.
 
UNC paths are usually only what I use. Try browsing to the UNC path by
clicking on Start then Run and copy the path in from the machine that you
are executing File.Exists from. If you can't get there then as stated
earlier the machine isn't seeing the path correctly.

If you can get there then are you executing the code under the same context
as the user that you are trying the Start - Run?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top