2

C # Relative path

 2 years ago
source link: https://www.codesd.com/item/c-relative-path.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

C # Relative path

advertisements

Hello I have a program made in Visual Studio in C#. In this program I have some pictures that need to be called. And some html files that need to be saved. All these files are saved in the map 'mails'. At the moment I have the path:

 String pad = @"C:\Users\Charlotte\Desktop\proof of concept\mails\";

I need this path to be relative so the user of the program can just copy the map mails to wherever he/she wants it and execute the exe of my program and just work with it.

Can anyone help me?


You can use function: Directory.GetCurrentDirectory() to get the path of current directory instead of telling program the fullpath.

Related Articles

Using the relative path in a maven project

I have a maven project with these standard directory structures: src/main/java src/main/java/pdf/Pdf.java src/test/resources src/test/resources/files/x.pdf In my Pdf.java, File file = new File("../../../test/resources/files/x.pdf"); Why does it

Related paths in scripts executed by cron jobs

I'm setting up my first cron job and it's not working. I think the problem may be a relative path issue. Given cron job: */1 * * * * python2.7 /home/path/to/my/script/my_script.py and my_script.py: import sqlite3 db = sqlite3.connect('my_db.db') cur

How to use relative paths in ReSharper DotSettings layers

We want to share .DotSettings between several solutions. The goal is to have one CodeStyle.DotSettings that we reference as a layer in all our X.sln.Dotsettings. However, I am seeing unexpected behaviour when I add the layer. I go to "Manage Options&

Custom 404 pages are unable to post because of relative path issues

My site currently implements custom 404 pages which we have mapped in IIS. So when a user does something like www.mysite.com/foo/bar/doesnotexist, it will execute the 404.aspx URL. This works great, but when inspecting the HTML returned, the form pos

JSP includes the directive, jsp: include action, relative paths relative to absolute paths

I am doing some basic templating in my JSP-based webapp. For example, I want to have a standard header and footer (basic HTML) that I pull into each of my JSPs. My content JSP is at /WEB-INF/jsp/home.jsp, and I have template JSPs at /WEB-INF/jsp/temp

Which uses the absolute or relative path?

I have one web application developed using Spring MVC. I have a jsp page where I am embedding the same application's page into iframe using an absolute path as below. I deploy the app in tomcat. Using jQuery on click of tab: $('#iframeId').attr('src'

Get the file size in Java from the relative path to the file

How can I get file size in Java if I have a relative path to a file such as: String s = "/documents/19/21704/file2.pdf/0929c695-d023-49d7-a8ff-65ccea46bebc" I tried with two diferent strings: String[] separatedPath = s.split("/"); List

Python relative path problems

I am trying to create some helper functions that will give me a folder based on the relative paths: def get_BASE_dir_path(): cur_dir = os.path.dirname(os.path.abspath(__file__)) BASE = os.path.abspath(os.path.join(cur_dir,"..","..")) r

How to read the file from the relative path in the Java project? Java.io.File can not find the specified path

I have a project with 2 packages: tkorg.idrs.core.searchengines tkorg.idrs.core.searchengines In package (2) I have a text file ListStopWords.txt, in package (1) I have a class FileLoadder. Here is code in FileLoader: File file = new File("properties

Relative path for xsl: import or xsl: include

I am trying to use VBScript to do an XSLT transform on an XML object. The XSL file I'm translating includes the <xsl:import href="script.xsl"/> directive. If I use the absolute URL (http://localhost/mysite/script.xsl), it imports the style

Creating a relative path to a known folder

I'm looking for a way to make a list of files from a relative filepath. So far I've come up with this: string[] filePaths = Directory.GetFiles(@"~\Images\Uploaded\"); But I get an error which says that the path doesn't exist, although it does.If

Copy the LAMP site to WAMP: relative paths do not work

I'm developping a website using MAMP and it is currently live on some Apache server, and working fine. However, a friend of mine copied the whole thing in the root directory of his WAMP server and on his machine, no relative path work (no includes, n

How to pass the relative path in the assignment

i have following code and when i pass absolute path my project works but i need relative path configuration.ini is a file which is in my current project so when i give absolute path, like this ,the code never runs <app Settings <add key="Config

Resolve the absolute path of the relative path and / or filename

Is there a way in a Windows batch script to return an absolute path from a value containing a filename and/or relative path? Given: "..\" "..\somefile.txt" I need the absolute path relative to the batch file. Example: "somefile.tx

How to get a relative path in ASP.NET MVC

How do you calculate a relative path in ASP.NET MVC?To include an image or a script or any other file this is the code: <script src="<%= Url.Content("~/Scripts/tiny_mce/jquery.tinymce.js") %>" type="text/javascript"&

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK