relative-path

Problem with relative path in System.file.io of asp.net

这一生的挚爱 提交于 2019-12-13 05:39:49
问题 I'm storing the file path in the database as ~/FolderName/FileName and when i try to open the file using System.IO.FileInfo(filePath) in this manner. It is not able to decipher the file path. Moreover i'm using this statement in a class DownloadFile, so i'm not able to use Page.Server.MapPath. Is there a work around for this problem. These are the following lines of code that i'm using: if (dr1.Read()) { String filePath = dr1[0].ToString(); HttpContext.Current.Response.ContentType =

javascript: how can I know where is the .js self?

痞子三分冷 提交于 2019-12-13 05:14:39
问题 I write a small javascript library, it use a image. I want to build the directory structure like this: /lib /mylib main.js /img main.png /other libraries... index.html But if I hard-code the image path lib/mylib/img/main.png , my library can't be used in other directory structure. What I want is to use "relative path" which relative to the main.js self. So that I can write path + 'img/main.png' to access the image. How can I know where is the main.js? 回答1: You can extract it from your <script

Use Relative path in place of absolute path

本秂侑毒 提交于 2019-12-13 04:59:21
问题 First of all i request people do not consider it as a duplicate question, please look into query. I am copying the xml files from one folder to other folder, in the source folder, i have some files which have some content like "backingFile="$IDP_ROOT/metadata/iPAU-SP-metadata.xml" but while writing to the destination folder. i am replacing the "$IDP_ROOT" with my current working directory. The entire copying of files is for deploying into tomcat server. The copying is done only when server

relative client url to http url

你离开我真会死。 提交于 2019-12-13 04:45:43
问题 I have a property of a model class that contains a relative url to a file. ~/_docs/folder/folder/document.pdf How I can, in the view, transform it to an hyperlink to download the file itself? thanks 回答1: <a href="<%= Url.Content("~/_docs/folder/folder/document.pdf") %>"> document.pdf </a> Or to make this more elegant and avoid the spaghetti code you could write a custom html helper: public static class HtmlExtensions { public static MvcHtmlString ContentLink( this HtmlHelper htmlHelper,

WPF Dispay image from relative location

放肆的年华 提交于 2019-12-13 03:59:19
问题 I would like to display an image on my dialog which could be located in a directory relative to the one the .exe is located in, e.g. project - data -- logo //<-- that's where the image is located -bin //<-- that's where the .exe is in A default image should be included in the .exe but on displaying the dialog, the \data\logo directory should be checked first and if an image with the given filename could be found there that one should be used for display instead of the one that is inside the

Relative Uri works for BitmapImage, but not for MediaPlayer?

若如初见. 提交于 2019-12-13 03:39:36
问题 This will be simple for you guys: var uri = new Uri("pack://application:,,,/LiftExperiment;component/pics/outside/elevator.jpg"); imageBitmap = new BitmapImage(); imageBitmap.BeginInit(); imageBitmap.UriSource = uri; imageBitmap.EndInit(); image.Source = imageBitmap; => Works perfectly on a .jpg with Build Action: Content Copy to Output Directory: Copy always MediaPlayer mp = new MediaPlayer(); var uri = new Uri("pack://application:,,,/LiftExperiment;component/sounds/DialingTone.wav"); mp

How do I appropriately put and use project resources with a built jar?

笑着哭i 提交于 2019-12-13 01:09:39
问题 I have a project having the following folder: resources/xml-schemata/someXMLschema.xsd A class inside my project uses this xml schema to validate xml files before importing them. This class has a local variable pointing out the schema path: schemaFilePath = "resources" + File.separator + "xml-schemata" + File.separator + "someXMLschema.xsd" Of course this works locally. Now I want to put my tool in a jar to give to other people. But the project using the jar can't find the schema, because of

In Ruby, how do I specify a file in another directory as an input?

こ雲淡風輕ζ 提交于 2019-12-12 22:19:33
问题 This probably has a simple answer, but I'm working on a test suite that requires an input file that is in a different folder. I'd like to use a relative path, like this: @graph = Graph.new('../lib/test_input.txt') But Ruby doesn't like that. What's the best way to use a relative file path like that? Thanks 回答1: If you mean relative to the current file, you'll probably want something like: @graph = Graph.new(File.expand_path(__FILE__, "../lib/test_input.txt")) If you mean relative to the

Mapping Absolute / Relative (Local) Paths to Absolute URLs

若如初见. 提交于 2019-12-12 20:42:16
问题 I need a fast and reliable way to map an absolute or relative local path (say ./images/Mafalda.jpg ) to it's corresponding absolute URL, so far I've managed to come up with this: function Path($path) { if (file_exists($path) === true) { return rtrim(str_replace('\\', '/', realpath($path)), '/') . (is_dir($path) ? '/' : ''); } return false; } function URL($path) { $path = Path($path); if ($path !== false) { return str_replace($_SERVER['DOCUMENT_ROOT'], getservbyport($_SERVER['SERVER_PORT'],

Allowing relative paths only

和自甴很熟 提交于 2019-12-12 16:23:23
问题 I believe this is an Apache .htaccess issue, and yet, maybe not. Maybe I am looking at the problem from the wrong angle, and thus can't find the proper solution. I am building a web app + hybrid mobile app. I would like to share the exact same code base, without having to tweak anything manually to deploy my app to Android or iOS, otherwise, the process of deploying will be hacky and painful. What I want is to take the web app repository, shove it into Cordova's box (you dirty man ;) , and it