This topic is locked
[SOLVED]

How to extract file names from field data?

2/24/2022 3:49:04 PM
ASPRunner.NET General questions
Pete K author

I have a table that contains a file upload field, which may contain one or more files. In the after record added event, I add the values of certain fields to an email. When I view the value of the "Documents" field containing the files, the output is a sort of JSON looking string that contains information about the files (name, usrName, type, etc.) which is confusing to the end user. They only want to see the file name(s). If I were smarter, I would be able to extract just the values of the "usrName" parts, which contains only the file names. But I can't figure out how to do this in C#.

Here's an example value, which contains two uploaded files:

[Documents, [{"name":"E:\\WebResources\\webapps_Resource\\Interpreter2/test.html_efxs5px7.doc","usrName":"test.html.doc","size":55,"type":"application/msword","searchStr":"test.html.doc,!This is an attachment.docx,!:sStrEnd"},{"name":"E:\\WebResources\\webapps_Resource\\Interpreter2/This is an attachment_lzzjnrpt.docx","usrName":"This is an attachment.docx","size":12299,"type":"application/vnd.openxmlformats-officedocument.wordprocessingml.document"}]]

Can anyone help me with some code to extract from this just the two file names? (in this case "test.html.doc" and "This is an attachment.docx")

Pete K author 2/25/2022

Figured it out. All I had to do is use ViewControl.Format(). I always seem to foget about that function.