I have 2 Files:  C:\Program Files\MyApp\images\image.png  C:\Users\Steve\media.jpg   Now i want to calculate the File-Path of File 2 (media.jpg) relative to File 1:  ..\..\..\Users\Steve\   Is there a built-in function in .NET to do this?
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.
Configuring dpkg stops processing when calling an HTTP request to Adobe Flash Player I recently moved to Linux, and I am in love with the experience. Opinions apart, I am having problems when running sudo dpkg --configure -a  My computer stops processing the command here:  You may know Adobe Flash Player is no longer supported, and I believe that could be why the command is unable to load pepperflashplugin-nonfree. I have tried fixing the problem by checking older posts here, but none of them was able to fix this problem. What are best practices for blocking UI when application is busy I'm writing a web app using Twitter Bootstrap with PHP on server side. My app makes regular ajax requests via jQuery and i want to disable certain parts of the UI until the server completes processing and hands back the control to Client-Side.  I wonder what would be best practices for the same? Does Microsoft Office 2010 have version control?  In other words, does it automatically save old versions of files? Parenthesis vs brackets for matrices When I first learned linear algebra, both the professor and the book used brackets like [ and ] to enclose matrices. However, in my current differential equations textbook, matrices are enclosed by parenthesis, and I suddenly realize everybody else are using them too.  So are brackets/parenthesis for enclosing matrices always totally interchangeable? What are the blue dots next to App names in iOS and macOS? They disappear once you open the apps and then return to the home screen, but I can't tell what they indicate.  Are they apps that haven't been opened since an app update? Or that it thinks have never been opened (not accurate in my case, but that could be a function of a "restore" confusing the phone). Get last insert id after a prepared insert with PDO I want to use the get_option() function of wordpress in one of my theme's files, which is not related to WP, it is just located in the same directory of the other theme files. I need this file because of some extra IPN paypal related actions, but I need some values from the options table that exists in WP to be called in this page in order for it to work. I know I can't just use get_option() as this file is overlooked by wordpress. Is there any approach by including some parts of wordpress in my theme to make this functionality only work? Unable to open Chrome WebDriver in another language I'd really like to write a Selenium WebDriver test that verifies text is localized. The localization code bases the strings it displays on navigator.language (or navigator.userLanguage for IE). I cannot figure out, however, how to launch a Chromium window for a different language.  I see this bug which sort of explains the problem (closed as not a bug):   Here's how I create the browser instance:  var webdriver = require('selenium-webdriver'); var chrome = require("selenium-webdriver/chrome");  var options = new chrome.Options(); options.addArguments('--lang=es'); var caps = options.toCapabilities(); var driver = webdriver.Builder().withCapabilities(caps).build();   I installed the Spanish language, but whereas navigator.languages includes es in its list, but even if I move it to the top of the preferences, en-US is still what navigator.language is set to.  Have any of you found a way to successfully write multi-language tests with Selenium WebDriver? Cannot dismiss scrollbar in code box, blocks view This question is a duplicate of  (but this question can't be marked as a duplicate because that question is on meta.stackoverflow.com, and this question is on meta.stackexchange.com).  I'm seeing a bug on stackoverflow.com. I'm not sure if the culprit is Stack Overflow, Google Chrome, or macOS.  (Below I refer to a "code box". By that I mean some text that begins with 4 spaces when editing a question or answer.)  When I hover over a code box that contains one long line of code, a horizontal scrollbar appears. When I stop hovering over the code box, very frequently (maybe 3 out of 4 times) the scrollbar does not disappear. Clicking elsewhere on the page also does not dismiss the scrollbar. The only way to dismiss it is to refresh the page.  ...After experimenting more, it appears to always happen if I enter the box from below, but not always when I enter from above. It seems to be triggered by hovering over the lower half of the box.  Also if I enter from the top and scroll to the right, then until I refresh the page again that scrollbox will behave normally (only show a scrollbar when scrolling, and disappear after). In that case the scrollbar also has a different appearance, being much less tall (maybe a quarter of the height of the code box rather than half as tall).  Further, if I get a box and scrollbar into that functional state and then hover over the lower part of the box for a bit, then sometimes eventually it will break and stay broken until refresh again.  And in any case hovering over the lower part of the box causes the scrollbar to get taller.  Here is a screenshot of the issue:        Google Chrome 71.0.3578.98 (Official Build) (64-bit)  macOS High Sierra 10.13.6  Here is a code box that repros the issue for me:  fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo   Here is another:  foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo Does a differentiable everywhere function have a continuous derivative? If a function $f$ defined on $[a,b]$ and differentiable everywhere, does it mean that its derivative $f'(x)$ is continuous everywhere on $[a,b]$?  My understanding is 'yes'. Because if there were 'a gap' in $f'(x)$, we could integrate back to $f(x)$ and show that where the gap is, there would be a sharp "angle" where $f(x)$ is not differentiable. How to calculate the sum of sequence $$\frac{1}{\binom{n}{1}}+\frac{1}{\binom{n}{2}}+\frac{1}{\binom{n}{3}}+\cdots+\frac{1}{\binom{n}{n}}=？$$ How about its limit? Combinatorics riddle: keys and a safe There are 8 crew members, The leading member wants that only a crew of 5 people or more could open a safe he bought, To each member he gave equal amount of keys, and locked the safe with several locks.  What's the minimal number of locks he should put:   at least 5 crew members would be required to open the safe? Any team of 5 crew members could open the safe, but none of the 4 team crew members.   1,2 stands individually of course. Biblatex with Biber: Configuring my editor to avoid undefined citations How do I pass a variable by reference? US tourism/business visa from non-resident country Replace a long string with the sed command: Argument list too long error I'm trying to execute this command  sed -i -e "s/BASE_64/$BASE_64/" FILE_NAME   where $BASE_64 is a base 64 representation of a file content.  sed gives me an error since the string is too long.     Argument list too long   How is it possible to avoid this error? Prove that inequality is true for $x>0$: $(e^x-1)\ln(1+x) > x^2$ I was given a task to prove that inequality is true for x>0: $(e^x-1)\ln(1+x) &gt; x^2$. I've tried to use derivatives to show that the $f(x) = (e^x-1)\ln(1+x)-x^2$ is greater than zero, but has never succeeded.  Any help will be appreciated. I am trying to make a simple pie chart with pgf-pie, but for a reason unknown to me the labels I use don't display correctly.   Here is the chunk of code I've copied from the manual into my .tex file :  \begin{tikzpicture}     \pie[color ={ cyan!10 , cyan!40, cyan!70,  cyan!100}, explode=0.1] {10/A, 20/B, 30/C, 40/D} \end{tikzpicture}   Here is a screenshot of what I get :    And here is a picture of what I'd like to obtain :   Does anybody knows why I get these numbers and how to get rid of them ?  edit : Here is a minimal working example   \documentclass{article} \usepackage[frenchb]{babel} \usepackage{pgf-pie}  \begin{document} \begin{tikzpicture}     \pie[color ={ cyan!10 , cyan!40, cyan!70,  cyan!100}, explode=0.1]{10/A, 20/B, 30/C, 40/D} \end{tikzpicture} \end{document} Is a semigroup with unique right identity and left inverse a group? We know that a semigroup with a right identity and right inverse for all elements is a group (e.g. see ). Symmetrically, also a left identity together with a left inverse implies a group. We also know that a semigroup with a right identity and a left inverse is NOT necessarily a group (see ). My questions are:   in a semigroup, is the existence of a UNIQUE right identity together with the existence of a left inverse enough to have a group? in a semigroup, is the existence of a right identity together with the existence of a UNIQUE left inverse enough to have a group?   I think both these claims are false,  ut haven't found a counter-example so far. Writing test code for wrapper class