User1210767569 posted
I have the below code working in it's own project but line For Each separator In {"-", "_", " "} fails in my VB.net project. Is this part c#? I have tried converting with no joy. http://www.developerfusion.com/tools/convert/csharp-to-vb/?batchId=c98c4294-68a0-4d85-a5ee-e01a95fcd5dc
Dim fileName = "1_2.pdf".Trim() ' Trim used to show you the method, here nonsense
Dim name = Path.GetFileNameWithoutExtension(fileName).Trim()
For Each separator In {"-", "_", " "}
Dim index = name.IndexOf(separator)
If index >= 0 Then
name = name.Substring(0, index)
End If
Next
fileName = String.Format("{0}{1}", name, Path.GetExtension(fileName))