relative-path

Relative to absolute path in java

我与影子孤独终老i 提交于 2020-01-06 12:56:35
问题 I have have a file that I want to use in my project which is in the resources package src.res Following what was stated in this answer, I believe that my code is valid. File fil = new File("/res/t2.nii"); // Prints C:\\res\\t2.nii System.out.println(fil.getAbsolutePath()); The problem is that I that file is in my projects file not there, so I get an Exception. How am I suppose to properly convert from relative path to absolute? 回答1: Since you are using a Java package, you must to use a class

Import-Module Verbose output implies module is loaded twice

若如初见. 提交于 2020-01-06 03:01:08
问题 I have a module ( MyModule ) under a non-standard path, i.e. not under the usual locations listed in $env:PSModulePath -split ";" . I have, however, added the "production" path to MyModule to that environment variable while I continue to work on a "development" copy. Whilst trying to debug something, I loaded the module (with $VerbosePreference = "Continue" ) using the following command and immediately saw two seemingly contradictory lines of Verbose output: [D:\Dev\UserA\]> Import-Module D:

PHP: How to get URL of relative file

眉间皱痕 提交于 2020-01-05 13:09:31
问题 Does PHP have a native function that returns the full URL of a file you declare with a relative path? I need to get: "http://www.domain.com/projects/test/img/share.jpg" from "img/share.jpg" So far I've tried the following: realpath('img/share.jpg'); // Returns "/home/user/www.domain.com/projects/test/img/share.jpg" I also tried: dirname(__FILE__) // Returns "/home/user/www.domain.com/projects/test" And this answer states that the following can be tampered with client-side: "http://'.$_SERVER

Converting Relative links to Absolute?

谁说我不能喝 提交于 2020-01-05 04:21:09
问题 I am programming a small script using PHP and regular expressions The aim of this script is to extract all links in a page and convert these links to absolute- when it is relative - I figured how does relative links works but their are some questions also lets say we have this page http://www.example.com/xxx1/xxx2/xxx3.html if this page has the following links index.html --- the absolute link will be http://www.example.com/xxx1/xxx2/index.html ./index.html --- the absolute link will be http:/

Meson working with data/assets and portable/relative paths

柔情痞子 提交于 2020-01-03 03:32:10
问题 I'd like to use Meson to build a little game in C++. Let's say that theses are my file: . ├── img │ └── img.png ├── meson.buid └── src ├── main.cpp └── meson.build Here are the meson.buid files: # meson.build project('mygame', 'cpp') subdir('src') pkgdatadir = join_paths(get_option('datadir'), 'mygame') install_subdir('img', install_dir : join_paths([pkgdatadir, 'img'])) And the second file: # src/meson.build executable('mygame', 'main.cpp', install : true) In my C++ code, what path should I

Extracting relative paths from absolute paths

笑着哭i 提交于 2020-01-02 09:29:13
问题 This is a seemingly simple problem but I am having trouble doing it in a clean manner. I have a file path as follows: /this/is/an/absolute/path/to/the/location/of/my/file What I need is to extract /of/my/file from the above given path since that is my relative path. The way I am thinking of doing it is as follows: String absolutePath = "/this/is/an/absolute/path/to/the/location/of/my/file"; String[] tokenizedPaths = absolutePath.split("/"); int strLength = tokenizedPaths.length; String

how to read text file relative path

喜欢而已 提交于 2020-01-01 04:36:30
问题 I have read sources here & there, but did not get the following code working. Basically, I wish to read a text file, named 'Administrator' from the folder 'src'. I will need a relative path, since this project may be transferred to another person. Please be patient with me. public void staffExists () throws IOException { //http://stackoverflow.com/questions/2788080/reading-a-text-file-in-java BufferedReader reader = new BufferedReader(new FileReader(getClass().getResourceAsStream ("

Changing C# .dll references from absolute to relative

寵の児 提交于 2020-01-01 04:13:25
问题 I have compiled my project and some of my project's added .dlls have absolute references. When I try to run my project on another machine, it looks for the .dlls from the original project path. How can I make the project look for the .dlls using a relative path? 回答1: Edit the .csproj file and change the <HintPath> elements from absolute paths to relative paths. 回答2: You may also write your handler for resolving assemblies. In the simplest form it may look like this: AppDomain.CurrentDomain

How to execute programs in the same directory as the windows batch file?

心已入冬 提交于 2019-12-31 08:14:09
问题 I have in the same folder a .bat and a .exe file. I couldn't call the .exe file from the .bat unless I put the full absolute path to it. Is there a way to don't specify the path? 回答1: Try calling the .exe with %~dp0 , like this: %~dp0MyProgram.exe . %0 contains the full path to the called .bat file. ~dp says to get the drive and path, including trailing \ . 回答2: I solved this by changing the working directory using pushd at the start of the script and restoring is at the end of the script

How to get the relative of a folder from two different projects

白昼怎懂夜的黑 提交于 2019-12-31 03:59:26
问题 I have two projects and one shared library that loads images from this folder: "C:/MainProject/Project1/Images/" Project1's folder: "C:/MainProject/Project1/Files/Bin/x86/Debug" (where there is project1.exe) Project2's folder: "C:/MainProject/Project2/Bin/x86/Debug" (where there is project2.exe) When I call the shared library function to load images, I need to obtain the relative path of "Images" folder, because I will call the function from either project1 or project2. Also I will move my