c# - Format string in ICS Fle (Set font for ICS file) -


i creating ics file fromc# wpf application , using following code generate ics file.

streamwriter writer; writer = new streamwriter(filepath); writer.writeline("begin:vcalendar"); writer.writeline("version:2.0"); writer.writeline("prodid:myapp"); writer.writeline("calscale:gregorian"); writer.writeline("method:publish"); writer.writeline("begin:vevent"); string startdatetime = convert.todatetime(appointmentdetails.startdate).tostring("yyyymmdd't'hhmmss"); string enddatetime = convert.todatetime(appointmentdetails.enddate).tostring("yyyymmdd't'hhmmss");  writer.writeline("dtstart:" + startdatetime); writer.writeline("dtend:" + enddatetime); writer.writeline(@"description:" + appointmentdetails.body); writer.writeline("summary:" + appointmentdetails.subject); writer.writeline("end:vevent"); writer.writeline("end:vcalendar"); writer.close(); 

but have problems while fromating description.i think when add \n new line ,it creates problem. need format string this.

------------------ header1 ----------------- body1 contents --------------- 

i using following line create dotted line.

result += new string('-', characterlength) + "\\n"; 

but out put showing 1 line instead of dotted line.i think “\n” creates problem.when add space after new line escape character can see problem solved.is there better/alternate solution this?

some string in description showing in different font style.how can make unique?

how can set font ics file c#?

please suggest.

first: should try find icalendar library, rather writing yourself. format complex, , there's lot of small stuff you're missing.

every line should around 75 bytes max. if line not fit (because it's bigger) can split line injecting real newline (\r\n) followed space or tab.

an icalendar reader remove \r\n[space] or \r\n\t.

you gotta make sure don't break file in middle of multibyte utf-8 sequence though.

the value description must encoded such :

  • ; must become \;
  • , must become \,
  • any new-line must become literal \n or \n

does help? if not, please post full output if icalendar stream can tell made mistake.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -