I need to get the full path of a file. I am using path.GetFullPath(“FileName”) it comes back with the wrong path.
The file name I use is LegSysDisplay_03072025.png
This is the path is comes back with
“C:\Users\kbetts\OneDrive - DOI\UiPath Bots\HealthCheck_Basis\HealthCheck_Basis_InitialBuild\LegSysDisplay_03072025.png”
but this is the actual path
“C:\Users\kbetts\OneDrive - DOI\UiPath Bots\HealthCheck_Basis\HealthCheck_Basis_InitialBuild\Data\Screenshots\Dev1\LegSysDisplay_03072025.png”
Why is it missing the last three folder levels?
There is no other file with the same name in the first path.
Anil_G
(Anil Gorthi)
March 7, 2025, 6:40pm
2
@kasey.betts
To explain the path.getfullpath will work based on current directory…whereever the file is it appenda the current directory path to it
So as the current directory for the project is the based project folder you are getting the same
You need to use path.GetFullpath("Data\Screenshots\Dev1\LegSysDisplay_03072025.png") to get the path as you expect
Cheers
Hi @kasey.betts
[Path.GetFullPath(“LegSysDisplay_03072025.png”)] is returning the wrong path because it looks for the file in the current working directory. To get the correct path, provide the full relative path to the file, like this:
fullPath = Path.GetFullPath(@“Data\Screenshots\Dev1\LegSysDisplay_03072025.png”);
If this information is helpful, please mark as solution. Thanks @kasey.betts
system
(system)
Closed
March 10, 2025, 6:49pm
4
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.