Code:

FileInfo fi = new FileInfo("\\intranet.xyx.com\abc\efg\def.txt");
if (!fi.Exists)
Console.WriteLine("Doesnt exist!");

Prints doesnt exist whereas this file actually exists. It works fine with files on my computer but.

Is the method to access this file(on the intranet) wrong.

Infact, the VB code for the same:

try
Dim dummy As String = FileSystem.Dir("\\intranet.xyx.com\abc\efg\def.txt") 'This will cause an error if file is missing
System.Console.Write("yay")

Catch ex As Exception
System.Console.Write("NAy")
End Try

Works well!!!

Any help appreciated.. !!!

try to map the intranet folder to a local drive.. should work this way.

i didnt exactly understand what you meant by mapping.

All i want to do is check if the file exists or not. Will mappping helP?

Im saying maybe if you map: \intranet.xyx.com\abc\efg\

to a local drive .. for ex. P:\

.. if i understood correctly its giving you problems when using a network path or what?

OR

is the implementation giving you problems? if so try:

if (System.IO.File.Exists("\\server\file.txt"))
            {
            }

i am not able to map. I used:
Subst K: \\server\file
but it seems it cant find the file.
And yeah, I have a problem using the network path. No implementation issues.
Is any other solution available?
Its urgent. Thanks in advance.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.