Reputation: 41
<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...
Upvotes: 2
Views: 3643
Reputation: 311315
Note that items have the %(Filename)
and %(Extension)
well known item metadata:
<ItemGroup>
<Foo Include="@(Bar)" Filename="%(Filename)%(Extension)" />
</ItemGroup>
Upvotes: 1
Reputation: 35921
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>
Upvotes: 12