| | |
open file from root directory
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Oct 2008
Posts: 89
Reputation:
Solved Threads: 0
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
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.
C# Syntax (Toggle Plain Text)
System.Diagnostics.Process.Start("file.txt");
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.
•
•
Join Date: Aug 2008
Posts: 1,735
Reputation:
Solved Threads: 186
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.
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
•
•
Join Date: Aug 2008
Posts: 1,735
Reputation:
Solved Threads: 186
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.
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
•
•
Join Date: Aug 2008
Posts: 1,160
Reputation:
Solved Threads: 137
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\
Custom Application & Software Development
www.houseshark.net
www.houseshark.net
![]() |
Similar Threads
- need a sample project in VB.NET/ASP.NET (VB.NET)
- mkdir() failed (No such file or directory) (PHP)
- Open or Save file dialogues? (Python)
- Overview of UNIX (Getting Started and Choosing a Distro)
- Quick Reference for Linux Commands (Getting Started and Choosing a Distro)
- Files & streams? (C++)
- Cannot View Certain Menus on Websites (Web Browsers)
- Redirect of Google to Porn (Viruses, Spyware and other Nasties)
- VMWare Red Hat 9 VMWare Tools and DNS (*nix Software)
Other Threads in the C# Forum
- Previous Thread: Font style ,in Console
- Next Thread: Making windows nonResizable
| Thread Tools | Search this Thread |
.net access ado.net algorithm array barchart bitmap box broadcast buttons c# check checkbox client combobox connection console control conversion csharp custom database datagrid datagridview dataset datetime degrees deployment developer development draganddrop drawing editing encryption enum event excel file form format forms function gdi+ hospitalmanagementinformationsystem httpwebrequest image imageprocessing index input install java label list listbox mandelbrot math mouseclick mysql operator oracle path photoshop picturebox pixelinversion post priviallages. programming radians regex remote remoting richtextbox rows serialization server sleep socket sql statistics stream string table temperature text textbox thread time timer txt update uploadatextfile usercontrol validation visualstudio webbrowser windows windowsformsapplication winforms wpf xml






