How do you open a file from the root directory without have to type the complete path like C:\folder\subfolder\file.txt? I have

System.Diagnostics.Process.Start("file.txt");

It works fine when I type in the whole location but I need to send this file to another computer and it won't be in the same folder as it is now probably. I've tried moving the file around in the project folder and even put it in the debug folder with the .exe file.

I'm also using this same code to open a .exe file and I don't have to type in the whole path to get that, just file.exe. That works fine.

If the above were an exe, you could rely on the computers path to pick it up if it were in say windows or system32 etc, such as notepad. However, you would need to know where the file was before you could start it. Either the computers current directory would have to be set to the directory in question, or you would need to put the full path in your start process command.

Well, you could tell it specifically which app to open in, but as a general rule as long as the file extension is properly associated with an application eg, windows knows the equivelent of double click is to open it in something, it should trigger it.

Perhaps you could use the "Path" type like so Myfullpath = Path.GetFullPath(Myfile.txt) This should return something like 'C:\MyFolder\MySubFolder\Myfile.txt' in Myfullpath.

Along with all the previous, you MUST know where the file will be, whether that is remote or local. If it is remote you can use a unc path like \\192.168.1.100\shared\myfile.txt. A possibly better solution would be to use mapped network drives, and not necessarily hard code all these paths. If its on a remote machine you can access it like Z:\myfile.txt as long as Z is mapped to \\192.168.1.100\shared\

kindly help me...........
i make the project in vb.net.suddenly my lap top is off after whan we open the then this error show.......................
project file could not be loaded.root file is missing??
plz my help me what are u doing

This article has been dead for over six months. Start a new discussion instead.