Forum: Ruby on Rails delete a file from the server

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Aaabfab1671252620c8bc01a374b5bd8?d=identicon&s=25 Jon Thomas (johnson)
on 2007-01-08 16:19
Hi all,

i want to create a vcs file. when i am creating the vcs file it is
getting creatd in the server as well as in the local drive. But i dont
want to the vcs file to be saved  in the serve. when  i am trying to
delete the file from the server it is throwing the error,"Cannot start
Microsoft Outlook.Cannot import vCalendar file". here is the code that i
am using.

def vcs
    f = File.open("txt_name.vcs","w+")
    f.syswrite("BEGIN:VCALENDAR\n")
    f.syswrite("PRODID:-//Microsoft Corporation//Outlook MIMEDIR//EN\n")
    f.syswrite("VERSION:1.0\n")
    f.syswrite("BEGIN:VEVENT\n")
    f.syswrite("DTSTART:20070105T210000Z\n")
    f.syswrite("DTEND:20070105T230000Z\n")
    f.syswrite("LOCATION:My office\n")
    f.syswrite("CATEGORIES:Business\n")
    f.syswrite("DESCRIPTION;ENCODING=QUOTED-PRINTABLE:This is a note
associated with the meeting\n")
    f.syswrite("SUMMARY;ENCODING=QUOTED-PRINTABLE:Meeting to discuss
something unwanted !!\n")
    f.syswrite("PRIORITY:3\n")
    f.syswrite("END:VEVENT\n")
    f.syswrite("END:VCALENDAR\n")

    f.close

    #value=StringIO.open("txt_name.vcs")


     send_file File.ree'txt_name.vcs', :type => 'text/x-vCalendar',
:disposition => 'attachment'

    if(File.exists?("txt_name.vcs"))
    File.delete("txt_name.vcs")
    end


  end


 plz do help me out. thanks in advance.
regards,
john.
2da252cc1d2fb3701126171831b50a65?d=identicon&s=25 Dave Coleman (pezdude)
on 2007-01-08 16:47
>      send_file File.ree'txt_name.vcs', :type => 'text/x-vCalendar',
> :disposition => 'attachment'
>
Just a guess...

Looks like your script is dieing when it tries to open the vcard in
outlook, therefore doesn't get to the delete action.

Your delete file code looks right.
This topic is locked and can not be replied to.