ApollonCY
ApollonCY

Reputation: 11

C# - Remote Access to Text File

I would like to access/read a text file that resides on a remote windows server. The local computer and the remote server are not connected to each other i.e. they are not part of a network or under a domain. Is there any possible way, using C#, to access and read the contents of that text file?

P.S.: The remote server requires a username and a password to log on to it. I'm the server admin and thereby I am aware of those credentials.

Thank you in advance!

Upvotes: 0

Views: 1460

Answers (2)

ApollonCY
ApollonCY

Reputation: 11

Hello and thanks for the replies! I have exposed the contents of the remote text file using a RESTful service. The local computer can now use the data stored in that text file by just navigating to the url where the service output is returned.

Upvotes: 0

MDV
MDV

Reputation: 195

C# is a programming language. You could implement a Windows service application that will listen to connections and then dump the contents of anything you'd like. There is nothing natively implemented in C#, however, that will allow you to immediately do what you're asking.

As long as both machines have internet access, and the network they're on will allow outside connections past the firewall, there are some examples online that will get you heading in the right direction. Example.

Be wary, however, that if you implement your own server application that will host files over the internet, you will have to also implement your own credential checking mechanism. Even if your server requires authentication, that will have no affect on your server application.

Upvotes: 1

Related Questions