c# - Filehelpers - Export with double quotes around each field EXCEPT when field is blank/null -


i may have missed answer when searching have file needs fields double quoted except when field blank, missing or null comma entered.

i'm using [fieldquoted('"', quotemode.alwaysquoted)] sample following output:

"mary","smith","555-555-5555","","1234","","3141 pi cr." 

but need output this:

"mary","smith","555-555-5555",,"1234",,"3141 pi cr." 

any suggestions using filehelpers?

you can use inotifywrite event modify output before writing file.

for instance

[delimitedrecord(",")] class product : inotifywrite // <-- implement events {     [fieldquoted(quotemode.alwaysquoted)]     public string name;     [fieldquoted(quotemode.alwaysquoted)]     public string description;     [fieldquoted(quotemode.alwaysquoted)]     public string size;      public void beforewrite(beforewriteeventargs e)     {     }      public void afterwrite(afterwriteeventargs e)     {         // replace occurrences of ,"", ,,         e.recordline = e.recordline.replace(",\"\",", ",,");     } } 

Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo