Click here to Skip to main content
15,895,740 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi all,

If this is possible at all how can I open a file which is located on a server connected to the LAN?
I am in need of the code in VB.net.

Thanks in advance!
Posted
Updated 18-Feb-11 2:42am
v3
Comments
Abdul Quader Mamun 18-Feb-11 8:13am    
Yes you can do it with required credential.

As Abdul already stated if you have the correct credentials it's quite easy. Another requirement would be to be on the LAN or have a VPN tunnel to said system it's also possible you there is a remote connection server running on your server and a remote desktop client on your local machine.

I'll go with the simplest solution though that relies on the process accessing the file running with administrative privelidges: You can use this to access the files on the server.

VB
Dim fileName as String
'On every server there are administrative shares for all drives
fileName = @"\\ServerName\c$\temp\file.txt"
Dim fs as new FileStream(fileName)
Dim sr as new StreamReader(fs)
Dim line as String
Do
    line = sr.ReadLine()
    Console.WriteLine(Line)
Loop Until line Is Nothing


If there are drives D,E and F then these would be accessible by shares d$, e$ and f$. The alternative is to have somebody (server administrator for instance) set up a share that lets you access the files you need.

Hope that helps you!

Cheers,
 
Share this answer
 
v3
first you have to create a folder on the other computer
then make in share and set security policy

and finally you can use this code

VB
Dim Sr As New System.IO.StreamReader("\\ComputerName\Share Folder Name\FileName")
Dim Data As String = Sr.ReadToEnd.ToString
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900