Path.Combine is handy, but is there a similar function in the .NET framework for Urls?
I'm looking for syntax like this:
which would return:
Of course, string concatenation would be fine here since the
'//' would be handled intelligently by the browser. But it feels a little less elegant.
Uri has a constructor that should do this for you: new Uri(Uri baseUri, string relativeUri)
Here's an example:
Uri baseUri = new Uri("http://www.contoso.com"); Uri myUri = new Uri(baseUri, "catalog/shownew.htm");
What is the proper way to modify environment variables like PATH in OS X? I've looked on google a little bit and found 3 different files to edit:
I don't even have some of these, and I'm pretty sure that .tcshrc is wrong, since osx uses bash now. Anybody have any idea where these variables, especially PATH, are defined?
Edit: I'm running OS X 10.5
Bruno is right on track. I've done extensive research and if you want to set variables that are available in all GUI apps, your only option is
1) Open a terminal prompt
sudo vi /etc/launchd.conf (note: this file might not yet exist)
3) Put contents like the following into the file
# Set environment variables here so they are available globally to all apps # (and Terminal), including those launched via Spotlight. # # After editing this file run the following command from the terminal to update # environment variables globally without needing to reboot. # NOTE: You will still need to restart the relevant application (including # Terminal) to pick up the changes! # grep -E "^setenv" /etc/launchd.conf | xargs -t -L 1 launchctl # # See http://www.digitaledgesw.com/node/31 # and http://stackoverflow.com/questions/135688/setting-environment-variables-in-os-x/ # # Note that you must hardcode the paths below, don't use enviroment variables. # You also need to surround multiple values in quotes, see MAVEN_OPTS example below. # setenv JAVA_VERSION 1.6 setenv JAVA_HOME /System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home setenv GROOVY_HOME /Applications/Dev/groovy setenv GRAILS_HOME /Applications/Dev/grails setenv NEXUS_HOME /Applications/Dev/nexus/nexus-webapp setenv JRUBY_HOME /Applications/Dev/jruby setenv ANT_HOME /Applications/Dev/apache-ant setenv ANT_OPTS -Xmx512M setenv MAVEN_OPTS "-Xmx1024M -XX:MaxPermSize=512m" setenv M2_HOME /Applications/Dev/apache-maven setenv JMETER_HOME /Applications/Dev/jakarta-jmeter
4) Save your changes in VI and reboot your Mac. Or use the grep/xargs command show in the code comment above.
5) Prove that your variables are working by opening a Terminal window and typing
export and you should see your new variables. These will also be available in IntelliJ and other GUI apps you launch via Spotlight.
Can anyone explain the difference between
Server.MapPath("."), Server.MapPath("~"), Server.MapPath(@"\") and Server.MapPath("/")?
Server.MapPath specifies the relative or virtual path to map to a physical directory.
Let's say you pointed a web site application (http://www.example.com/) to
and installed your shop application (sub web as virtual directory in IIS, marked as application) in
For example, if you call Server.MapPath in following request:
If Path starts with either a forward (
/) or backward slash (
\), the MapPath method returns a path as if Path were a full, virtual path.
If Path doesn't start with a slash, the MapPath method returns a path relative to the directory of the request being processed.
Note: in C#, @ is the verbatim literal string operator meaning that the string should be used "as is" and not be processed for escape sequences.