How to get the full path of a file?
How to get the full path of a file?
416
14-Jul-2023
Updated on 15-Jul-2023
Aryan Kumar
15-Jul-2023There are several ways to get the full path of a file. Here are a few methods:
Path.GetFullPath()methodThe
Path.GetFullPath()method is a method in thePathclass that can be used to get the full path of a file. ThePath.GetFullPath()method takes a file name as input and returns the full path of the file as output.For example, to get the full path of a file named
myfile.txt, you would use the following code:GetAbsolutePath()methodThe
GetAbsolutePath()method is a method in theSystem.IO.FileInfoclass that can be used to get the full path of a file. TheGetAbsolutePath()method takes aFileInfoobject as input and returns the full path of the file as output.For example, to get the full path of a file named
myfile.txt, you would use the following code:.NET File System APIThe .NET File System API provides a number of methods that can be used to get the full path of a file. For example, the
System.IO.Path.GetFullPath()method can be used to get the full path of a file.For example, to get the full path of a file named
myfile.txt, you would use the following code:You can also get the full path of a file by using the Windows Explorer. To do this, open the Windows Explorer and navigate to the file that you want to get the full path for. Right-click the file and select Properties. In the Properties dialog box, the full path of the file will be displayed in the File location property.