473,385 Members | 1,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

System.IO.File.Exists

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

Feb 7 '06 #1
4 14995
CMM
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.

"raibeart" <ra******@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
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

Feb 7 '06 #2
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" <ra******@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
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

Feb 7 '06 #3
"raibeart" <ra******@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
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.
Feb 8 '06 #4
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?
"raibeart" <ra******@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
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

Feb 8 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: JW | last post by:
Hi, I am trying to see if I can display an animated .gif file on a Java application (that is, I do not want to have to show a series of static images to simulate animateion; I just want to...
2
by: Zeno Lee | last post by:
I'm using File.Exists to test a file on my C: drive. My program was strongly named and had caspol -af run on it to allow it to run from the network. There are 3 ways I am doing this: 1) Run...
3
by: anastasia | last post by:
I get an out of memory exception when attempting to excecute the following code: original = System.Drawing.Image.FromFile(file.FileName,true); I ONLY get this exception when the file is in the...
6
by: Chad Crowder | last post by:
Getting the following error on my production server whether the file exists or not: "System.IO.IOException: Cannot create a file when that file already exists." Here's the code generating the...
4
by: Elmo Watson | last post by:
Is there a way, with the System.IO class, to do a recursive list of a directory structure? For instance, in DirectoryInfo, you have GetDirectories and GetFiles .... In Directory, you have...
2
by: Stephen Witter | last post by:
I had previously posted this on the security ng, but haven't had a hit so I was wondering if someone here would be willing to take a stab. I am trying to copy a file to a network drive. I can do...
6
by: Don | last post by:
I'm having problems working with a streamwriter object. After closing the streamwriter and setting it to Nothing, I try to delete the file it was writing to, but I always get the following error...
5
by: Ronald S. Cook | last post by:
I'm trying to see if a file exists on a server. I have the below code which doesn't seem to work. Must I necessarily have a mapped drive to that the path starts with X:\ or similar? if...
3
brclancy111
by: brclancy111 | last post by:
Hello. I've been programming for 1 year now, and never saw this coming... When I try to use File.Exists("Data/Settings.dat") it does absolutely nothing. I am trying to build a system that...
7
by: sudhaMurugesan | last post by:
Hi all, I use asp.net with c#. I upload a file and save in a directory. I want to reopen the file so i check for file exists and then open it. But though the file exists, the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.