Reading a file using a relative path in a Python project

Relative paths are relative to current working directory. If you do not want your path to be relative, it must be absolute. But there is an often used trick to build an absolute path from current script: use its __file__ special attribute: from pathlib import Path path = Path(__file__).parent / “../data/test.csv” with path.open() as f: … Read more

Loading image from code using relative path in Windows Forms

For my program, Path.GetDirectoryName (Assembly.GetExecutingAssembly().Location) returns C:\code\test\Junk\bin\Debug. cell.Value = Image.FromFile( Path.Combine ( Path.GetDirectoryName (Assembly.GetExecutingAssembly().Location), “Resources/warning_Icon”)); Of course, usually you would embed the resources in your assembly unless you want to change them without a recompile.

Java – Loading dlls by a relative path and hide them inside a jar

I don’t believe you can load the DLL directly from the JAR. You have to take the intermediary step of copying the DLL out of the JAR. The following code should do it: public static void loadJarDll(String name) throws IOException { InputStream in = MyClass.class.getResourceAsStream(name); byte[] buffer = new byte[1024]; int read = -1; File … Read more

PHP: How to resolve a relative url

Perhaps this article could help? http:// nashruddin.com/PHP_Script_for_Converting_Relative_to_Absolute_URL Edit: reproduced code below for convenience <?php function rel2abs($rel, $base) { /* return if already absolute URL */ if (parse_url($rel, PHP_URL_SCHEME) != ” || substr($rel, 0, 2) == ‘//’) return $rel; /* queries and anchors */ if ($rel[0]==’#’ || $rel[0]==’?’) return $base.$rel; /* parse base URL and convert … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)