absolute-path

ASP.NET MVC - Find Absolute Path to the App_Data folder from Controller

走远了吗. 提交于 2019-11-26 18:08:48
What is the correct way to find the absolute path to the App_Data folder from a Controller in an ASP.NET MVC project? I'd like to be able to temporarily work with an .xml file and I don't want to hardcode the path. This does not work: [HandleError] public class HomeController : Controller { public ActionResult Index() { string path = VirtualPathUtility.ToAbsolute("~/App_Data/somedata.xml"); //.... do whatever return View(); } } I think outside of the web context VirtualPathUtility.ToAbsolute() doesn't work. string path comes back as "C:\App_Data\somedata.xml" Where should I determine the path

Absolute vs. relative paths

倖福魔咒の 提交于 2019-11-26 17:32:44
问题 If I use absolute paths, I can't move the whole directory to a new location. If I use relative paths, I can't move individual files to new locations. What's the solution here? Do you set up a config file that holds the root path and go from there? Or do you have a rule like: Never move files around? I've seen in some projects that people use dirname( FILE ). What is the point of that, I mean, why not simply leave it out since the dirname is relative anyway (depending on where the file sits)?

Get path of Android resource

放肆的年华 提交于 2019-11-26 15:26:01
My question is: is it possible to get the absolute path of a resource (in a subdirectory of the res/ folder) in Android? Most of the answers I see to this question on google suggest getting a file descriptor, implying that this is not possible. Is it? EDIT: The reason I want to do this is because I'm writing classes that accept a path to media and play it. Testing would be much easier if I could pass the absolute path of a resource. HPP Use URI Paths instead of "absolute" path, see this post Uri path = Uri.parse("android.resource://com.segf4ult.test/" + R.drawable.icon); Uri otherPath = Uri

slash(/) vs tilde slash (~/) in style sheet path in asp.net

耗尽温柔 提交于 2019-11-26 15:11:56
How these 2 paths are resolved in asp.net. why these 2 gives different path. At what time we need to go for these. <link href="/common/black_theme/css/style.css" rel="stylesheet"> (this is working) <link href="~/common/black_theme/css/style.css" rel="stylesheet"> (this is not working) As per my knowledge ~ represents root directory of the application "Common" is the folder under root of the website(named testsite.demo) in IIS physical path = D:\Physicalpath\WarpFirstSite\testsite.demo common folder location - D:\Physicalpath\WarpFirstSite\testsite.demo\common / - Site root ~/ - Root directory

PHP include absolute path

我怕爱的太早我们不能终老 提交于 2019-11-26 14:21:46
问题 I have a variable on my site called $basePath which is set as: $basePath = '/Systems/dgw/'; I am using it on all my css, js and images tags as so (shortened for better visibility): <link href="<?php echo $basePath; ?>include/assets/css/bootstrap.min.css"> I have no problem with those includes and they work fine in wherever file and in whatever folder I am. I have a certain included page which has the following line: <img src="<?php echo $basePath; ?>images/new_logo.png" alt="logo"/> And the

How to find the working folder of a servlet based application in order to load resources

China☆狼群 提交于 2019-11-26 12:32:22
I write a Java servlet that I want to install on many instances of Tomcat on different servers. The servlet uses some static files that are packed with the war file under WEB-INF. This is the directory structure in a typical installation: - tomcat -- webapps --- myapp ---- index.html ---- WEB-INF ----- web.xml ----- classes ------ src ------- ..... ----- MY_STATIC_FOLDER ------ file1 ------ file2 ------ file3 How can I know the absolute path of MY_STATIC_FOLDER, so that I can read the static files? I cannot rely on the "current folder" (what I get in a new File(".")) because it depends on

ASP.NET MVC - Find Absolute Path to the App_Data folder from Controller

◇◆丶佛笑我妖孽 提交于 2019-11-26 12:15:41
问题 What is the correct way to find the absolute path to the App_Data folder from a Controller in an ASP.NET MVC project? I\'d like to be able to temporarily work with an .xml file and I don\'t want to hardcode the path. This does not work: [HandleError] public class HomeController : Controller { public ActionResult Index() { string path = VirtualPathUtility.ToAbsolute(\"~/App_Data/somedata.xml\"); //.... do whatever return View(); } } I think outside of the web context VirtualPathUtility

How to get the file-path of the currently executing javascript code

大城市里の小女人 提交于 2019-11-26 11:59:54
问题 I\'m trying to do something like a C #include \"filename.c\" , or PHP include(dirname(__FILE__).\"filename.php\") but in javascript. I know I can do this if I can get the URL a js file was loaded from (e.g. the URL given in the src attribute of the tag). Is there any way for the javascript to know that? Alternatively, is there any good way to load javascript dynamically from the same domain (without knowing the domain specifically)? For example, lets say we have two identical servers (QA and

What is my script src URL?

假如想象 提交于 2019-11-26 11:49:42
Is there a simple and reliable way to determine the URL of the currently-executing JavaScript file (inside a web page)? My only thought on this is to scan the DOM for all the script src attributes to find how the current file was referenced and then figure out the absolute URL by applying it to document.location . Anyone have other ideas, is there some super-easy method I completely overlooked? UPDATE: Script elements accessed via the DOM already have a src property which contains the full URL. I don't know how ubiquitous/standard that is, but alternatively you can use getAttribute("src")

python/zip: How to eliminate absolute path in zip archive if absolute paths for files are provided?

大城市里の小女人 提交于 2019-11-26 10:41:02
问题 I have two files in two different directories, one is \'/home/test/first/first.pdf\' , the other is \'/home/text/second/second.pdf\' . I use following code to compress them: import zipfile, StringIO buffer = StringIO.StringIO() first_path = \'/home/test/first/first.pdf\' second_path = \'/home/text/second/second.pdf\' zip = zipfile.ZipFile(buffer, \'w\') zip.write(first_path) zip.write(second_path) zip.close() After I open the zip file that I created, I have a home folder in it, then there are