Hello All,
I am displaying a form which has a dynamic dropdown menu. As you see in the picture, my drop down reads complete path. How to read only file name?
I have used assign function using System.IO.Directory.GetFiles (file path) as array of string. I am not able to see any option to read array of string without extension. I tried path.GetFileNameWithoutExtension(AssignedPath) but this also gives me error and doesnt work.
No you don’t need to change it. x indicates a key for LINQ command to iterate every file in the list. You can use any name in Function, it doesn’t matter.
Then you’d use Find Children to get an array of all the options in the pulldown, then For Each through the array and use the Path.GetFileName on each item to get just the filename.
Oh then you need to change the value in the data that you’re passing to the form for the pulldown, before you open the form. For Each through the array you’ve got the full paths in, and add just the filename for each item into a list variable using Path.GetFileName
@supriya117 This works good if there is single file. I have multiple file in my folder. So my variable type become System.String and thats creating issue.
That’s not returning an array. That’s the expression you’d use if you were looping through your original array, and it returns string. This expression you assign to your existing array instead of your Directory.GetFiles:
new DirectoryInfo(YOUR_DIRECTORY).GetFiles().Select(Function(x) x.Name).ToList()