Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File.Exists doesn't work from network drive

Status
Not open for further replies.

arjacey

Technical User
Jan 22, 2007
12
GB
I have some very simple (and I DO mean very simple) VB.NET code. Build to c:\ drive works OK but copying the exe to a mapped network drive always returns that the file is not found.

--------------------------
Imports System.IO

Public Class fCAU

Private Sub fCAU_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If File.Exists("c:\a.txt") Then
MsgBox("c:\a.txt found")
Else
MsgBox("c:\a.txt not found")
End If
Me.Close()
End Sub
End Class

I have had a 'fiddle' with the security settings but have hit on nothing that has made a difference.

Any clues, anyone?

 
Try using the mapped network path. On our Intranet, the drive spec is F:; however, not every computer is mapped the same.

Therefore, when I access the network path, I always use the shared name: \\srvchidc1\shared\pathname...

As for security, are you speaking of running an .exe from the intranet? If so, you must go to Control Panel > Adiministrative Tools > Microsoft .NET Framework X.X Wizards.

Double click the icon, choose intranet, and set the security level to low.

I hope this helps.



Ron Repp

If gray hair is a sign of wisdom, then I'm a genius.
 
A network file is not going to be under c:\, Its going to be under z:\ or what ever letter you mapped it to...
 
Thanks for your time.

To clarify, this program should check for the existence of a file on the PC local drive (c:) but I want the user to be able to run the program from a server location (j:, as it happens but thats not important right now).

So when I run it from the c:\ drive, it finds the file but taking a copy of the exe to the j: drive and running it from there says it can't find the file, although the file is present.

Thanks for your time so far.

 
If you are running a .Net application from a network share you have to go into the control panel\admin tools\.Net security configuration and either 1)Explicitly trust that assembly, 2)Explicitly trust that network share, or 3)Reduce the level of security for the entire network.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Rick

Thanks.

I've clicked soem buttons and it's working.

I'm not sure I'm youing another for another learning curve...

 
Extended Mercury Autocode then...
Algol 68 then...
PL/1 then...
Cobol then...
little bit of Assembler (to much like hard work!) then...
PDS 7.1 Basic then...
VBA in Access 2 onwards then...
VB5, VB6 and now...
VB.NET

So I'm trying to apply the techniques from Acccess VBA (which I develop as heavily code-based systems) and DAO to VB.NET, ADO.NET and all the other NET technologies.

My current VB.NET learning/'to be used' project is one to roll out front end code mdb updates to user workstations.

Check this forum regularly for more idiot questions :)
 
As mentioned, try using fully qualified UNC paths rather than drive letter mappings.

for example instead of "j:\smithjohn" you would specify "\\MyServerName\MyShareName\smithjohn".

You could even replace the MyServerName with the IP address of the server.

A collegue of mine always uses mapped drive letters so whenever I modify his code, I have issues as his "I:\" is mapped to a different share than my "I:\" but a fully qualified UNC path will always find the desired destination regardless.
 
After re-reading this thread, I have to ask you a strange question, are you tring to run the application on a different computer?
In other words, you have built an application that refs files at c:\ and you have put this application on a different pc, now you are trying to run the app from your computer?
If so, it wont work because when you run the app "j:\someapp.exe", your pc will download it to memory on your computer then run it, the app will have no connection to the remote computer at all, and will ref your local c:\. There are ways to do this kind of thing with Remote Process Call(RPC) i think?.

If I am way off, then I apologise...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top