Need to remove the filename in the path

Hello Guys

I need to remove the filename in the path.

Task is :
- The bot will enter the file path as per the condition and the folder structure
- To take the count of files that are present inside the path with the same name.

Eg path

C:\User\This\is\Sample\Folder…many more directories(Dynamically changes) \FG0025_1.txt

C:\User\This\is\Sample\Folder…many more directories(Dynamically changes) \FG0034CR_1.txt

I have taken the whole path by screen scrapping and tried with regex my bad didn’t get proper output

Is there any way to remove the file name and extension

Regards
Sudharsan

Hi,

Just to understand why do you screenscrape? Are you working in Citrix?

Your scraped string: myFullPath = "C:\User\This\is\Sample\Folder…many more directories(Dynamically changes)\FG0034CR_1.txt"

Just the folder:
path.GetDirectoryName(myFullPath)
→ C:\User\This\is\Sample\Folder…many more directories(Dynamically changes)

Just the file:
path.GetFileName(myFullPath)
→ FG0034CR_1.txt

Just the file without extension:
path.GetFileNameWithoutExtension(myFullPath)
→ FG0034CR_1

Just the file extension:
path.GetExtension(myFullPath)
→ .txt

Just the root folder:
path.GetPathRoot(myFullPath)
→ C:\

3 Likes

Hi @Deebiga_Kandasamy

As I said earlier the folder structure will not be constant ,so to get the path and to get the file count I have used screen scrapping

Hi @Jeroen_van_Loon

I’ll try this , Thanks brother

Regards
Sudharsan

Working fine
Thanks Man @Jeroen_van_Loon

Regards
Sudharsan

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.