0

I'm looking for a way to translate a file path on a specific PC to an absolute network path that can be used by any other computer on the same LAN. I'm fairly new to networking stuff, so forgive me if there's errors in my terminology.

When I say a file path on a specific PC, I don't mean that the file resides on that PC; the file path could reside on the PC (e.g. "C:\Foo\Bar\File.exe"), or it could be a mapped drive pointing to a folder on the same PC or another PC on the LAN. What I need to do is translate it into a form that isn't PC-specific; if I send the address to another PC on the LAN, that PC should be able to find the file. I'm not sure if I'm on the right track, but I think UNC might be the way to go.

Basically, I'm creating an application that remotely runs executables, consisting of a server (which runs on one PC) and client application (which runs on the other PCs). The user selects the file to execute on the server application using an OpenFileDialog (which can be on the same PC, or on the LAN), and it will then be converted into an absolute network path.

After determining the absolute network path, the server application will then use it to find the IP of the PC that the file resides on; if I'm correct, this could be extracted from the absolute network path. If the file is on the same PC, it will be executed; if not, a TCP or UDP connection will be made to the other PC, and the absolute network path will be sent to it.

At the other end, the client application running on the remote PC will pick up the absolute network path sent to it. It'd probably be best to check that the path points to a file on the same PC before continuing at this point. The client will then run the executable. I don't know whether I'll be able to use the absolute network path directly, or whether I'll have to convert it back into a PC-specific file path first in order to run the executable.

So long-story-short, I need to take a file path on a specific PC on a LAN and find both the name/IP of the PC that the file resides on, and an absolute network path that the PC in question can use to find the file.

Thanks!

Lee.J.Baxter
  • 495
  • 4
  • 12
  • So if I were to derive a UNC path, could I then use it to create a TCP connection to the same PC that the file resides on (I'm guessing I'd extract the first section of the UNC path in order to do this)? – Lee.J.Baxter Aug 22 '15 at 20:50
  • 1
    This, of course, requires that there be a share on the PC. But, yes, you should be able to extract the host name and make a TCP connection to it if there is something on the other side that can accept your connection. – Jeff Prince Aug 22 '15 at 20:54
  • Thankyou, I wasn't sure whether UNC was the way forward or not. There should be shares present on the local PC, as the executable files on the network will be selected from there using an OpenFileDialog; I'm guessing if the appropriate shares aren't present, then the user wouldn't be able to browse to the file on the local PC. – Lee.J.Baxter Aug 22 '15 at 21:07

0 Answers0