Answers for "get path"

11

python get current file location

import os
os.path.dirname(os.path.abspath(__file__))
Posted by: Guest on May-11-2020
2

get file path

On Windows explorer :
Hold shift and right click on the file
Select "Copy file path to clipboard" (this may change with windows versions and languages)
Paste the content of your clipboard in a document.
Posted by: Guest on June-18-2021
2

python get path of current file

import pathlib
pathlib.Path(__file__).parent.absolute()
Posted by: Guest on April-04-2020
0

Get directory path of file path

string filePath = @"C:\MyDir\MySubDir\myfile.ext";
string directoryName = Path.GetDirectoryName(filePath);
Console.WriteLine($"GetDirectoryName('{filePath}') returns '{directoryName}'");

//This code produce the following output:
GetDirectoryName('C:\MyDir\MySubDir\myfile.ext') returns 'C:\MyDir\MySubDir'
Posted by: Guest on September-17-2021

Python Answers by Framework

Browse Popular Code Answers by Language