Answers for "get file path"

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
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

Browse Popular Code Answers by Language