# Hot to access the text file and delete it

**URL:** <https://www.ruby-forum.com/t/hot-to-access-the-text-file-and-delete-it/123141>\
**Category:** Ruby\
**Created:** [December 14, 2007, 11:18am UTC](https://www.ruby-forum.com/t/hot-to-access-the-text-file-and-delete-it/123141 "2007-12-14T11:18:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ankush](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/8797f3/32.png) [@ankush](https://www.ruby-forum.com/u/ankush)\
**Post date:** [December 14, 2007, 11:18am UTC](https://www.ruby-forum.com/t/hot-to-access-the-text-file-and-delete-it/123141/1 "2007-12-14T11:18:34Z")

</div>

How do i access the text file and delete the file. This file gets  
generated periodically. So i need to make a script for d same so that i  
can delete it just by running the ruby script

---

<div class="post-metadata">

**Author:** ![ankush](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/8797f3/32.png) [@ankush](https://www.ruby-forum.com/u/ankush)\
**Post date:** [December 14, 2007, 11:19am UTC](https://www.ruby-forum.com/t/hot-to-access-the-text-file-and-delete-it/123141/2 "2007-12-14T11:19:14Z")

</div>

Ankush Regundwar wrote:

> How do i access the text file and delete the file. This file gets  
> generated periodically. So i need to make a script for d same so that i  
> can delete it just by running the ruby script

“I was able to access the file but not able to delet it”

---

<div class="post-metadata">

**Author:** ![ankush](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/8797f3/32.png) [@ankush](https://www.ruby-forum.com/u/ankush)\
**Post date:** [December 14, 2007, 1:03pm UTC](https://www.ruby-forum.com/t/hot-to-access-the-text-file-and-delete-it/123141/3 "2007-12-14T13:03:28Z")

</div>

Ankush Regundwar wrote:

> How do i access the text file and delete the file. This file gets  
> generated periodically. So i need to make a script for d same so that i  
> can delete it just by running the ruby script

Are you looking for something like

File.open(“testrm”, “w+”) { do\_stuff }  
File.delete(“testrm”) ! 1
