3

How to get the full directory path

 2 years ago
source link: https://www.codesd.com/item/how-to-get-the-full-directory-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.

How to get the full directory path

advertisements

I have create a directory name 'DbInventory' in E drive of my machine Now in my c# application I want to get the full path of this directoty(DbInventory).

bellow I am mentioning the code I have used

DirectoryInfo info = new DirectoryInfo("DbInventory");
string currentDirectoryName = info.FullName;

But this currentDirectoryName string return the file location in C drive.


First of all, DirectoryInfo constructor takes parameter as a string with full path. When you just write a folder name, it gets the location of your Visual Studio's default path which is most common in your C:/ drive and under Bin/Debug folder.

So in my computer, your currentDirectoryName will be;

C:\Users\N53458\Documents\Visual Studio 2008\Projects\1\1\bin\Debug\DbInventory

If you want to get full path name, you can use Path.GetDirectoryName method;

Returns the directory information for the specified path string.

Related Articles

How to get the full file path from the Google Drive via java

I am java developer .I integrated google drive to my application using google app client_id and client_secrect . Based on this client_id i got the access token of the user .After getting the access token.I used the following code to get files and fol

How to get the home directory path in App.config?

From app.config I want to dynamically get the base directory path where project exe is present. Is that possible? For example, in C# code we can write the following to get the path. string executablePath = AppDomain.CurrentDomain.BaseDirectory Is the

How to get the full file path (image file) using AngularJs

I need to get the full file name using directive with angularjs , Bellow is my code, here I am only getting file name. Is it possible to get the full file name? <input type="file" fileread="justice.imageLocation" /> MyApp.directi

Extension with image: How to get the full image path in the model?

I have created a Typo3 extension using the Extension Builder. One of those fields is an image field. When rendering an entity in the frontend I have access to this field like: {entity.image} <!-- results in image.jpg without a path --> But it only r

How do I get the full directory path of the current file in Python?

I want to get the current file's directory path. I tried: >>> os.path.abspath(__file__) 'C:\\python27\\test.py' But how can I retrieve the directory's path? For example: 'C:\\python27\\' If you mean the directory of the script being run: import o

How to get the web directory path from Entity?

I researched the How to Handle File Uploads with Doctrine and I don't want to hard-code the __DIR__.'/../../../../web/'.$this->getUploadDir(); path because maybe in future I will change the web/ directory. How to do it more flexible? I found this but

How to get the full file path using the input type file in javascript?

I want to implement an attachment feature for email, like Gmail has, using jquery+javascript. So I use input type file to select the file - which gives only the name of file, not the full path of file where it is located. I want the full path of file

How to get the parent directory in Python?

Could someone tell me how to get the parent directory of a path in Python in a cross platform way. E.g. C:\Program Files ---> C:\ and C:\ ---> C:\ If the directory doesn't have a parent directory, it returns the directory itself. The question might

How to get the complete directory in Java with the file name

How to get the file Directory plus the full name so i can assign it to the variable inFile below are the type of data i want to read i have used the regular expression but it did not works public void loadAfileFinal() throws FileNotFoundException { F

How to get the full web address with BeautifulSoup

I cannot find how to get the full address of a web site: I get for example "/wiki/Main_Page" instead of "https://en.wikipedia.org/wiki/Main_Page". I cannot simply add url to the link as it would give :"https://en.wikipedia.org/wik

How to get the isolated storage path to access files and folders in the Windows Phone7 application?

In windows mobile 6 applications, I use code like Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) to get the application path. Likewise in windows phone7 application, how to get the isolated storage path an

How to get the full path to archive that & ldquo; know & rdquo; when working in the debugger

I have an XML file I'm streaming as an XDocument. I need to be able to get the full path of the file (NOT the bin/Debug path) using reflection or the like (so this will be the path from the User's machine it lives on). I have tried about a zillion di

How to get the full path to a file in VBScript?

I am using the Shell.Application object, which allows me to script creation of a zip file. But in order for this to work, I need to full path of the zip file. File.zip doesn't work. I need c:\the\full\path\file.zip, even if the script is running with

android: how to get the full path of a file stored in a folder in sdcard?

I am working in android. i want to get the full path of a file selected by user. my files are stored in sdcard. but may be in a folder in sd card. I have some folders in my sdcard. I want to get the full path of a file on which i click. Suppose I hav

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK