# Delete a file from the server

**URL:** <https://www.ruby-forum.com/t/delete-a-file-from-the-server/81372>\
**Category:** Rails\
**Created:** [January 8, 2007, 4:19pm UTC](https://www.ruby-forum.com/t/delete-a-file-from-the-server/81372 "2007-01-08T16:19:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tirsen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/f475e1/32.png) [@tirsen](https://www.ruby-forum.com/u/tirsen)\
**Post date:** [January 8, 2007, 4:19pm UTC](https://www.ruby-forum.com/t/delete-a-file-from-the-server/81372/1 "2007-01-08T16:19:37Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![tirsen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/f475e1/32.png) [@tirsen](https://www.ruby-forum.com/u/tirsen)\
**Post date:** [January 8, 2007, 4:47pm UTC](https://www.ruby-forum.com/t/delete-a-file-from-the-server/81372/2 "2007-01-08T16:47:20Z")

</div>

> ```
> 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.
