relative-path

How do I find a file that may not be fully-qualified by using the environment path?

我怕爱的太早我们不能终老 提交于 2019-11-30 17:29:34
问题 I have an executable name, like "cmd.exe" and need to resolve it's fully-qualified path. I know the exe appears in one of the directories listed in the PATH environment variable. Is there a way to resolve the full path without parsing and testing each directory in the PATH variable? basically I don't want to do this: foreach (string entry in Environment.GetEnvironmentVariable("PATH").Split(';')) ... There has to be a better way, right? 回答1: This seems like a pretty good way of doing it

Relative paths with fetch in Javascript

為{幸葍}努か 提交于 2019-11-30 17:13:58
I was surprised by an experience with relative paths in Javascript today. I’ve boiled down the situation to the following: Suppose you have a directory structure like: app/ | +--app.html +--js/ | +--app.js +--data.json All my app.html does is run js/app.js <!DOCTYPE html> <title>app.html</title> <body> <script src=js/app.js></script> </body> app.js loads the JSON file and sticks it at the beginning of body : // js/app.js fetch('js/data.json') // <-- this path surprises me .then(response => response.json()) .then(data => app.data = data) The data is valid JSON, just a string: "Hello World" This

Is it possible to make a shortcut to a relative path in Windows that runs as admin?

a 夏天 提交于 2019-11-30 16:25:44
问题 To create a shortcut with a relative path, set the target to the following. %windir%\system32\cmd.exe /c start your_relpath\app.exe [your_args] It is also straightforward to make the program run as administrator. Properties > Advanced > Run as administrator But putting the two together doesn't work. When cmd.exe is started as admin, it loses the current working directory and goes to %windir%\system32 . The relative path starts there which is not intended. Is there any way to make a shortcut

Retrieving relative url path of file inside a include file, jsp

爷,独闯天下 提交于 2019-11-30 15:53:30
I have a file called Main.jsp, located at the absolute url path of "http://Mywebpage.com/Open/This/Folder/Main.jsp". Inside Main.jsp, there is a jsp include: <%@ include file="../../Top.jsp" %> Now, inside the Top.jsp page, I have other jsp and javascript statements which reference files: <%@ taglib uri="emonogram.tld" prefix="em" %> ... <script type="text/javascript" src="HL.js"></script> emonogram.tld and HL.js are stored in the same directory as Top.jsp, i.e. "http://Mywebpage.com/Open/". I need Top.jsp to be flexible enough, such that any file can reference it, no matter where it is in the

getting base url of web site's root (absolute/relative url)

孤街醉人 提交于 2019-11-30 15:19:58
问题 I want to completely understand how to use relative and absolute url address in static and dynamic files. ~ : / : .. : in a relative URL indicates the parent directory . : refers to the current directory / : always replaces the entire pathname of the base URL // : always replaces everything from the hostname onwards This example is easy when you are working without virtual directory. But i am working on virtual directory. Relative URI Absolute URI about.html http://WebReference.com/html/about

Relative file paths in Python packages

情到浓时终转凉″ 提交于 2019-11-30 14:42:02
问题 How do I reference a file relatively to a package's directory? My directory structure is: /foo package1/ resources/ __init__.py package2/ resources/ __init__.py script.py script.py imports packages package1 and package2 . Although the packages can be imported by any other script on the system. How should I reference resources inside, say, package1 to ensure it would work in case os.path.curdir is arbitrary? 回答1: If you want to reference files from the foo/package1/resources folder you would

Convert absolute path to relative path in batch file

风流意气都作罢 提交于 2019-11-30 14:08:38
Is it possible to convert an absolute path to a relative path in a batch file? (the opposite of this ). Obviously you would need two inputs: the absolute path to convert, and an absolute reference path that you want it to be relativised to. eg: Path to convert: c:\documents\mynicefiles\afile.txt Reference path: c:\documents Result: mynicefiles\afile.txt @echo off setlocal EnableDelayedExpansion set Path_to_convert=c:\documents\mynicefiles\afile.txt set Reference_path=c:\documents set Result=!Path_to_convert:*%Reference_path%\=! echo Result: %Result% Here is another method that works if your

Preferred way to include relative reference to JavaScript in VS 2008 nested Masterpage

心不动则不痛 提交于 2019-11-30 13:57:27
Our base Masterpage has something like the following <head runat="server"> <title></title> <script type="text/javascript" src="<%= Page.ResolveClientURL("~/javascript/actions.js")%>"></script> <script type="text/javascript" src="<%= Page.ResolveClientURL("~/javascript/jquery/jquery-1.2.6.min.js")%>"></script> <asp:contentplaceholder id="cph_htmlhead" runat="server"> </asp:contentplaceholder> </head> If this Masterpage is the Masterpage for an ASPX page things work fine. If this Masterpage is the Masterpage for a child Masterpage and then a new ASPX page uses the child Masterpage as it's

Getting the relative path to the rdlc report in my winform app

帅比萌擦擦* 提交于 2019-11-30 13:42:29
I am automatically creating a PDF from some of our reports in a month-end process. I am running into a problem where ReportViewer.LocalReport can't find my report. Within the project, the report files are in "(project root folder)/Reports/report.rdlc". How do I set ReportViewer.LocalReport.ReportPath so I can reference my report file? I would rather not set the full path because I don't know where it would be installed when installed on the client machines. Use the Application.StartupPath property, it always points to directory where your EXE is located: using System.IO; ... string exeFolder =

Upstart node.js working directory

别来无恙 提交于 2019-11-30 11:49:10
Starting Node.js with Upstart, when trying to access files within Node.js it cannot access them without using the full path. I need it to use the working directory. start on startup stop on shutdown script echo $$ > /var/run/mynodeapp.pid exec sudo -u mynodeapp node server.js >> /var/log/mynodeapp.sys.log 2>&1 end script pre-start script echo "Starting" >> /var/log/mynodeapp.sys.log end script pre-stop script rm /var/run/mynodeapp.pid echo "Stopping" >> /var/log/mynodeapp.sys.log end script The solution is to change directory within the script. In my case, the user is mynodeapp and the node