I'm getting a file from an OpenFileDialog which returns a string with the absolute path to the selected file. Now I want that path as a relative path to a given path (in this case the path to my application).  So let's say I get a path to the file: c:\myDock\programming\myProject\Properties\AssemblyInfo.cs  and my application is located in  c:\myDock\programming\otherProject\bin\Debug\program.exe  then I want the result:   ..\..\..\myProject\Properties\AssemblyInfo.cs
There's a part in my apps that displays the file path loaded by the user through OpenFileDialog. It's taking up too much space to display the whole path, but I don't want to display only the filename as it might be ambiguous. So I would prefer to show the file path relative to the assembly/exe directory.  For example, the assembly resides at C:\Program Files\Dummy Folder\MyProgram and the file at C:\Program Files\Dummy Folder\MyProgram\Data\datafile1.dat then I would like it to show .\Data\datafile1.dat. If the file is in C:\Program Files\Dummy Folder\datafile1.dat, then I would want ..\datafile1.dat. But if the file is at the root directory or 1 directory below root, then display the full path.   What solution would you recommend? Regex?  Basically I want to display useful file path info without taking too much screen space.  EDIT: Just to clarify a little bit more. The purpose of this solution is to help user or myself knowing which file did I loaded last and roughly from which directory was it from. I'm using a readonly textbox to display the path. Most of the time, the file path is much longer than the display space of the textbox. The path is supposed to be informative but not important enough as to take up more screen space.  Alex Brault comment was good, so is Jonathan Leffler. The Win32 function provided by DavidK only help with part of the problem, not the whole of it, but thanks anyway. As for James Newton-King solution, I'll give it a try later when I'm free.
When are you supposed to use escape instead of encodeURI / encodeURIComponent? When encoding a query string to be sent to a web server - when do you use escape() and when do you use encodeURI() or encodeURIComponent():  Use escape:  escape("% +&amp;=");   OR  use encodeURI() / encodeURIComponent()  encodeURI("http://www.google.com?var1=value1&amp;var2=value2");  encodeURIComponent("var1=value1&amp;var2=value2"); How to reset Canon 70D WiFi? When I go to the WiFi Settings in Camera (Canon 70D) all I see is:  Connection:   Exit Confirm Set Error Details (greyed out)   I can't recall the password or find any way to reset it. Some I found () say the Camera should say Infrastructure mode. Inside the Confirm Settings I can see on page 3 it shows:     Connect'n method: Camera access point mode   But again I see no way to change this.  On my Smartphone EOS Remote app there's a Connection Guide with completely different menus from what I'm seeing on the Camera.  Any idea how I can reset the WiFi Name and Password on the Canon 70D? Apex Array Slice Sometimes I like to use a Queueable to perform work on a list of Ids or sObjects over the heaver Batchable Interface.   However, to do this, we need a very solid implementation of an Array slice method.  Most other programming languages have a native slice method, but Apex does not.  While I have written my own version of slice and it's working fine, I would be interested in hearing about other implementations of slice - the more efficient the better.  My version is in this Utilities class on github   It's modelled after the Javascript version described on the mozilla site   I would expect that the usage and output be similar to this:  String[] arr = ['zero', 'one', 'two', 'three']; String[] sliced = Utilities.slice(arr,1, 3);  System.debug(arr);      // ['zero', 'one', 'two', 'three'] System.debug(sliced);   // ['one', 'two'] I will soon buy a new iPhone. If I log in with my Apple ID in my new phone could I still access my Clash of Clans village without starting from scratch? Evaluation inside Button stops after some seconds I am really confused.  Which preposition is correct?     She is in/at the park.   They are in/at the park.   I am in/at the park.   Should I use in or at in these sentences? Can we interchange the sentences " What's the date today?" and "what day is it today?"  In grammar is it correct to use these sentences interchangeably?  For example "What's the day today?" and "what date is it today?" Suppose $X_n$ is the fortune of a gambler after $n$ th game. Then the game is called fair (Breiman 1968) if   $$E[X_{n+1} \mid X_1, \dots, X_n] = X_n \forall n$$  My question is why a fair game is not defined as the following   $$E[X_{n+1}] = E[X_n] \forall n$$ i.e. $$E[X_{n+1}- X_n]=0$$. This should be the proper definition as a fair game is where avg. gain is zero. Nothing conditioning should be there. Prove that $\left(\sum^n_{k=1}x_k\right)\left(\sum^n_{k=1}y_k\right)\geq n^2$ What is the difference between $* and $@? Consider the following code:  foo () {     echo $* }  bar () {     echo $@ }  foo 1 2 3 4 bar 1 2 3 4   It outputs:     1 2 3 4       1 2 3 4   I am using Ksh88, but I am interested in other common shells as well. If you happen to know any particularity for specific shells, please do mention them.  I found the follwing in the Ksh man page on Solaris:     The meaning of $* and  $@  is   identical  when  not  quoted  or  when  used  as a parameter   assignment value or as a file name. However, when used as  a   command argument, $* is equivalent to ``$1d$2d...'', where d   is the first character of the IFS variable,  whereas  $@  is   equivalent  to  $1 $2 ....   I tried modifying the IFS variable, but it doesn't modify the output. Maybe I'm doing something wrong? How to read "service --status-all" results I need to identify the currently running services but I can't figure out the results of running service --status-all, I mean what does ?, - and + mean ?  $ service --status-all  [ + ]  acpid  [ + ]  anacron  [ + ]  apparmor  [ ? ]  apport  [ ? ]  atieventsd  [ + ]  avahi-daemon  [ ? ]  binfmt-support  [ + ]  bluetooth  [ - ]  brltty  [ + ]  console-font  [ + ]  console-setup  [ + ]  cron  [ + ]  cups  [ + ]  cups-browsed  [ - ]  dbus  [ ? ]  dns-clean  [ + ]  friendly-recovery  [ - ]  grub-common  [ ? ]  irqbalance  [ - ]  kerneloops  [ ? ]  killprocs  [ + ]  kmod  [ ? ]  lightdm  [ - ]  lm-sensors  [ ? ]  mysql  [ ? ]  networking  [ ? ]  ondemand  [ ? ]  pppd-dns  [ - ]  procps  [ - ]  pulseaudio  [ ? ]  rc.local  [ + ]  resolvconf  [ + ]  rfkill-restore  [ + ]  rfkill-store  [ - ]  rsync  [ + ]  rsyslog  [ + ]  saned  [ ? ]  sendsigs  [ + ]  setvtrgb  [ ? ]  speech-dispatcher  [ - ]  sudo  [ + ]  timidity  [ + ]  udev  [ ? ]  umountfs  [ ? ]  umountnfs.sh  [ ? ]  umountroot  [ - ]  unattended-upgrades  [ - ]  urandom  [ + ]  virtualbox  [ - ]  x11-common   And would running this command with sudo make any difference ? I tried it and in my case it didn't make any difference, but may it differ in other setups ? I am trying to install Linux headers for Kali Linux on my machine and I have tried every possible solution on the internet but it always show "Unable to locate packages "  root@kali:/usr/sbin# apt-get install linux-headers-4.6.0-kali1-amd64 Reading package lists... Done Building dependency tree        Reading state information... Done E: Unable to locate package linux-headers-4.6.0-kali1-amd64 E: Couldn't find any package by glob 'linux-headers-4.6.0-kali1-amd64' E: Couldn't find any package by regex 'linux-headers-4.6.0-kali1-amd64'   Here is my sources.list file :  # Regular Repositories deb http://http.kali.org/kali sana main non-free contrib deb http://security.kali.org/kali-security sana/updates main contrib non-free # Source repositories deb-src http://http.kali.org/kali sana main non-free contrib deb-src http://security.kali.org/kali-security sana/updates main contrib non-free   Uname -a output :   root@kali:/usr/sbin# uname -a Linux kali 4.6.0-kali1-amd64 #1 SMP Debian 4.6.4-1kali1 (2016-07-21) x86_64 GNU/Linux iPhone 4 water damage - how to recover data? Arrow with plus/minus sign on top Below you can see an arrow with a plus and a minus sign on top of it. How is this achievable in latex? Further possibilities: arrow with only plus and arrow with only minus sign on top. How can I do this? How to sum a variable by group How to adjust the gap between figure and caption within the same subfloat My question is:  How to adjust the gap between figure and caption within the same subfloat  Not the gap between two subfloat.  For the following example:  \begin{figure}     \centering     \subfloat[A]{\includegraphics[ scale=0.5]{images/a.jpg}}     \vspace{-10pt}     \subfloat[B]{\includegraphics[scale=0.5]{images/b.jpg}}     \vspace{-10pt}     \caption{}\label{fig:online_test} \end{figure}   I got the following figure:    The sub-caption of (a) is too close to the sub-figure B. I hope the caption (a) to stay closer to sub-figure A. How can I adjust the space between the caption and figure within a subfloat?  Thank you all for helping me and I would prefer a solution for subfloat, instead of using other packages. But I would also appreciate a solution of using other packages.   I know my question looks similar to . But please make it clear. I'm asking for how to adjust the gap between figure and caption within a subfloat, not the gap between two subfloat. That is, the gap between the caption "a" and the figure "A"  Thank you. Can I uninstall and reinstall Ubuntu Software Center? Bind a key for multiple units to use the same spell How to Select Hyperlink Text in Google Chrome? I am running Google Chrome 5. How can I select hyper link text using the mouse with, for example, CTRL or ALT keys? I have just updated (through Software Update) to Ubuntu 16.04 LTS from 15.10. There are random instances of screen flickering throughout usage. After noticing this issue, I installed Compiz Config Settings Manager, selecting Force fulls screen redraws (buffer swap) on repaint, which did nothing.   Is there any way this could be related to compiz settings or is this another issue?    EDIT: not fixed after clean install, upgrade to kernel 4.5.2, however screen flickering is reduced, it is every now and then (10 minutes apart). I will see if upgrading to kernel 4.6.0-994-generic will fix this.     EDIT: fixed as of kernel 4.6.2 generic,  currently running 4.7.2 without any issues.