Answers for "how to get file path"

3

get file path java

File file = new File("yourfileName");
String path = file.getAbsolutePath();
Posted by: Guest on February-24-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
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

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language