Answers for "get path of file in local dir"

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:MyDirMySubDirmyfile.ext";
string directoryName = Path.GetDirectoryName(filePath);
Console.WriteLine($"GetDirectoryName('{filePath}') returns '{directoryName}'");

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

Browse Popular Code Answers by Language