Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get file name from path Msbuild

<PropertyGroup>
        <fileName>$(FilePath.Substring($(FilePath.LastIndexOf('\'))))</fileName>    
</PropertyGroup>

I tried the above code. But am getting the file name including the last '\'. For eg. \Data.xml. I need only Data.xml. How can I get it?

Thank you...

like image 990
Nims Avatar asked Nov 25 '25 12:11

Nims


1 Answers

You could add another Substring call or so to strip the first character, but more convenient and less error-prone is to use the proper System.IO.Path function, see Property Functions:

<PropertyGroup>
    <fileName>$([System.IO.Path]::GetFileName('$(FilePath)'))</fileName>    
</PropertyGroup>
like image 130
stijn Avatar answered Nov 28 '25 02:11

stijn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!