Create a text file in ASP.NET

We need the namespace, System.IO to use files.

The method, CreateText requires a string for an argument. The string is the path of file which will be created. After we have correctly written to the text file, we close the StreamWriter by invoking the Close method of StreamWriter. See below for example code.

<!DOCTYPE html>

<script runat="server">

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim TextFile As New System.IO.StreamWriter(Server.MapPath("test.txt"))
        TextFile.WriteLine("Lorem ipsum dolor sit amet, consectetur adipiscing elit.")
        TextFile.Close()
    End Sub

</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Button ID="Button1" runat="server" Text="Button" />
    </div>
    </form>
</body>
</html>
Updated: March 6, 2015 — 5:00 pm

Comments

Add a Comment
  1. Your comment is awaiting moderation.

    Truly all kinds of wonderful tips!
    https://www.dunamisproductions.com/
    pharmacy drug store
    canada pharmaceutical online ordering
    pharmacies near me
    canadian pharmacy online

  2. Your comment is awaiting moderation.

    Great forum posts. Kudos!
    https://www.waltcoexpress.com/
    northwest pharmacy
    canadian pharmacies
    canada pharmacy
    canada pharmaceutical online ordering

  3. Your comment is awaiting moderation.

    You suggested it wonderfully.
    https://www.dunamisproductions.com/
    canadian mail order pharmacies
    canada online pharmacies
    discount pharmaceuticals
    canada pharmaceutical online ordering

  4. Your comment is awaiting moderation.

    Very good info. Cheers.
    https://www.visitwaushara.com/
    canada pharmacies online pharmacy
    aarp approved canadian online pharmacies
    canadian drugstore
    online pharmacies canada

  5. Your comment is awaiting moderation.

    Many thanks! Valuable information!
    https://www.dunamisproductions.com/
    best online international pharmacies
    canadian online pharmacy
    prescription drugs online without doctor
    canadian pharmacies online

  6. Your comment is awaiting moderation.

    You made your point!
    https://www.lunarciel.com/
    pain meds online without doctor prescription
    canadian pharmacies-24h
    prescription drug price comparison
    canadianpharmacy

  7. Your comment is awaiting moderation.

    Fantastic tips. Cheers.
    https://www.waltcoexpress.com/
    pharmacy price compare
    canadian pharmacies
    online pharmacy without a prescription
    top rated canadian pharmacies online

  8. Your comment is awaiting moderation.

    You actually explained that fantastically.
    https://www.lunarciel.com/
    prescription without a doctor’s prescription
    mexican pharmacies shipping to usa
    canadian pharmacies that ship to us
    canadian online pharmacies

  9. Your comment is awaiting moderation.

    Thanks, Numerous facts!

    https://www.waltcoexpress.com/
    online discount pharmacy
    canada pharmacy
    prescription price comparison
    canada pharmacy

  10. Your comment is awaiting moderation.

    Amazing tons of amazing info.
    https://www.dunamisproductions.com/
    safeway pharmacy
    online pharmacies canada
    web medical information
    canadian pharmacy

  11. Your comment is awaiting moderation.

    You actually mentioned this well.
    https://www.visitwaushara.com/
    best canadian online pharmacy
    global pharmacy canada
    online pharmacy without a prescription
    canadian online pharmacies

  12. Your comment is awaiting moderation.

    Helpful write ups. With thanks!
    https://www.lunarciel.com/
    best canadian online pharmacy
    canadian pharmacies that ship to us
    highest rated canadian pharmacies
    canadian online pharmacies

  13. Your comment is awaiting moderation.

    Cheers. Excellent stuff!
    https://www.dunamisproductions.com/
    online drugs
    canada pharmaceuticals online
    canada pharmacies without script
    canadian pharmacy

  14. Your comment is awaiting moderation.

    Lovely forum posts. Thank you!
    https://www.dunamisproductions.com/
    top rated canadian pharmacies online
    canada pharmacy
    prescription drugs canada
    canadian pharmacies

  15. Your comment is awaiting moderation.

    Awesome advice. With thanks!
    https://www.interlandchemie.com/
    online canadian discount pharmacy
    canadian pharmacies online
    cheap drugs online
    canadian drugs

  16. Your comment is awaiting moderation.

    Regards! Plenty of data.

    https://www.interlandchemie.com/
    online discount pharmacy
    canada drug
    prescription drug assistance
    canadian pharmacies that ship to us

  17. Your comment is awaiting moderation.

    Thanks a lot. Excellent stuff!
    https://www.lunarciel.com/
    canadian pharmacies top best
    canadian cialis
    prescription drugs without doctor approval
    canada pharmaceuticals online

  18. Your comment is awaiting moderation.

    Awesome content. Thank you!
    https://www.visitwaushara.com/
    canadian pharmacies online prescriptions
    canadianpharmacy
    international pharmacy
    canadian drugs

  19. Your comment is awaiting moderation.

    Effectively voiced really! !
    https://www.dunamisproductions.com/
    canadian pharmacy without prescription
    canada pharmacy online
    24 hour pharmacy
    canada drug

  20. Your comment is awaiting moderation.

    Superb tips. Thanks.
    https://www.interlandchemie.com/
    international pharmacies that ship to the usa
    canadian pharmacies-24h
    medication costs
    top rated canadian pharmacies online

  21. Your comment is awaiting moderation.

    Thank you, Excellent stuff!
    https://www.waltcoexpress.com/
    online drugstore
    online pharmacies canada
    no prescription pharmacy
    global pharmacy canada

  22. Your comment is awaiting moderation.

    You have made the point!
    https://www.lunarciel.com/
    canadian pharmacy viagra
    canada pharmacy
    online drugs
    online pharmacies canada

  23. Your comment is awaiting moderation.

    You suggested it very well.
    https://www.lunarciel.com/
    canadian pharmacies online prescriptions
    canada pharmaceuticals online
    highest rated canadian pharmacies
    canadian viagra

  24. Your comment is awaiting moderation.

    Valuable forum posts. Thanks a lot.
    https://www.interlandchemie.com/
    canada pharmacy online
    canada pharmacy online
    trusted overseas pharmacies
    canada pharmaceutical online ordering

  25. Your comment is awaiting moderation.

    Nicely put. With thanks!
    https://www.interlandchemie.com/
    king pharmacy
    canada pharmacy online
    canada pharmacies
    canadian online pharmacies

  26. Your comment is awaiting moderation.

    Cheers, I enjoy this.
    https://www.lunarciel.com/
    pharmacy online
    canadian pharmacies that ship to us
    candrugstore com
    canadian cialis

  27. Your comment is awaiting moderation.

    Thanks! Numerous content.

    https://www.dunamisproductions.com/
    canada pharmacies without script
    canadian online pharmacy
    approved canadian pharmacies online
    aarp approved canadian online pharmacies

  28. Your comment is awaiting moderation.

    Seriously many of terrific info!
    https://www.dunamisproductions.com/
    mail order pharmacies
    canadian online pharmacy
    online canadian pharmacy
    canadian drugs

  29. Your comment is awaiting moderation.

    You said it adequately.!
    https://www.lunarciel.com/
    canadian pharmacy reviews
    canadian online pharmacy
    canadian pharmacies without prescriptions
    top rated canadian pharmacies online

  30. Your comment is awaiting moderation.

    Awesome material. Cheers!
    https://www.waltcoexpress.com/
    prescription drugs canada
    canadian drugs
    canada pharmacies
    canadian pharmacies

  31. Your comment is awaiting moderation.

    Lovely stuff, Cheers!
    https://www.visitwaushara.com/
    prescription drug cost
    global pharmacy canada
    canadian drugstore
    canadian pharmacy online

  32. Your comment is awaiting moderation.

    You actually mentioned that well!
    https://www.lunarciel.com/
    canada pharmacy
    canadian pharmacy online
    online pharmacy without a prescription
    northwest pharmacy

  33. Your comment is awaiting moderation.

  34. Your comment is awaiting moderation.

    Thank you! Ample knowledge.

    https://www.waltcoexpress.com/
    us pharmacy no prior prescription
    london drugs canada
    prescription without a doctor’s prescription
    canada drugs

  35. Your comment is awaiting moderation.

  36. Your comment is awaiting moderation.

    Position clearly taken!!
    https://www.dunamisproductions.com/
    canadian drug stores online
    online pharmacies of canada
    buy prescription drugs canada
    north west pharmacy canada

  37. Your comment is awaiting moderation.

    You revealed it effectively.
    https://www.visitwaushara.com/
    canadapharmacy
    canadian online pharmacies
    drugstore online
    northwestpharmacy

  38. Your comment is awaiting moderation.

    Many thanks. I value this.
    https://www.dunamisproductions.com/
    canadian mail order pharmacies
    canadian pharmacy
    global pharmacy canada
    trust pharmacy canada

  39. Your comment is awaiting moderation.

    Thanks. Numerous forum posts.

    https://www.visitwaushara.com/
    drug prices comparison
    aarp approved canadian online pharmacies
    mexican pharmacy online medications
    canadian pharcharmy

  40. Your comment is awaiting moderation.

    You actually revealed it superbly!
    https://www.dunamisproductions.com/
    canadian pharmacy uk delivery
    canada drugs online
    online pharmacy without a prescription
    canada pharmaceuticals online

  41. Your comment is awaiting moderation.

    Really a lot of amazing facts!
    https://www.interlandchemie.com/
    canadian pharmacy no prescription
    canadian cialis
    pharmacy price comparison
    canada pharmaceutical online ordering

  42. Your comment is awaiting moderation.

    Truly quite a lot of terrific knowledge.
    https://www.lunarciel.com/
    safeway pharmacy
    aarp approved canadian online pharmacies
    drugs without prescription
    canadian pharmacies that ship to us

  43. Your comment is awaiting moderation.

    You actually revealed it well!
    https://www.dunamisproductions.com/
    canadadrugs
    canadian pharmacies
    drug price
    north west pharmacy canada

  44. Your comment is awaiting moderation.

    Thank you. I appreciate this.
    https://www.interlandchemie.com/
    prescription pricing
    canada drug
    my canadian pharmacy
    london drugs canada

  45. Your comment is awaiting moderation.

    You mentioned it fantastically.
    https://www.waltcoexpress.com/
    canadapharmacy
    canadian online pharmacies
    candrugstore com
    online pharmacies of canada

  46. Your comment is awaiting moderation.

    Valuable postings. Appreciate it!
    https://www.interlandchemie.com/
    discount prescription drug
    global pharmacy canada
    rx price comparison
    london drugs canada

  47. Your comment is awaiting moderation.

    Thank you! Lots of content!

    https://www.lunarciel.com/
    canadian online pharmacy reviews
    mexican pharmacies shipping to usa
    international pharmacies that ship to the usa
    london drugs canada

  48. Your comment is awaiting moderation.

    Cheers, Numerous write ups!

    https://www.visitwaushara.com/
    price prescription drugs
    top rated canadian pharmacies online
    canada meds
    canadian pharmacies that ship to us

  49. Your comment is awaiting moderation.

    You actually explained it effectively!
    https://www.visitwaushara.com/
    canada pharmacies prescription drugs
    canadian pharmacies
    online rx pharmacy
    canadian pharmaceuticals online

  50. Your comment is awaiting moderation.

    Whoa quite a lot of good material!
    https://www.waltcoexpress.com/
    mexican pharmacies shipping to usa
    canadianpharmacy
    canadian cialis
    online pharmacies of canada

  51. Your comment is awaiting moderation.

    Thank you. An abundance of stuff!

    https://www.waltcoexpress.com/
    drug stores near me
    canadian pharmacies that ship to us
    walgreens pharmacy
    canada pharmaceuticals online

  52. Your comment is awaiting moderation.

    Really loads of amazing material.
    http://canadianpharmaciesnnm.com/
    online discount pharmacy
    canada pharmacy online
    online pharmacy reviews
    northwest pharmacy

  53. Your comment is awaiting moderation.

    Appreciate it, Numerous data.

    http://canadianpharmacysilo.com/
    pharmacy online store
    canada drugs online
    prescription drug assistance
    canada drugs

  54. Your comment is awaiting moderation.

    You mentioned that very well.
    http://canadianpharmacysilo.com/
    northwest pharmacy canada
    canadian pharmaceuticals online
    rx online
    canada pharmacy

  55. Your comment is awaiting moderation.

    You actually expressed it adequately.
    http://canadianpharmacysilo.com/
    legitimate online pharmacies
    canadian drugs
    medical information online
    canadian pharmacies without an rx

  56. Your comment is awaiting moderation.

    Truly lots of awesome data.
    http://canadianpharmaciesnnm.com/
    trust pharmacy canada
    top rated canadian pharmacies online
    canadian drugs without prescription
    trust pharmacy canada

  57. Your comment is awaiting moderation.

    Fine tips. Cheers!
    http://canadianpharmaciesnnm.com/
    canada pharmacies online prescriptions
    canada pharmacy online
    walgreens pharmacy
    canada online pharmacies

  58. Your comment is awaiting moderation.

    Appreciate it. A good amount of knowledge!

    http://canadianpharmaciesnnm.com/
    canadian cialis
    canada pharmacy online
    no prescription online pharmacy
    canada pharmaceutical online ordering

  59. Your comment is awaiting moderation.

    Great information. With thanks.
    http://canadianpharmaciescubarx.com/
    prescription drug cost
    canadian online pharmacy
    best non prescription online pharmacies
    canadian pharmaceuticals online

  60. Your comment is awaiting moderation.

    You expressed that effectively.
    http://canadianpharmacyntx.com/
    drugs online
    canada pharmacy
    cialis online
    canadian pharmacies-24h

  61. Your comment is awaiting moderation.

    Many thanks, I like it!
    http://canadianonlinepharmacynnm.com/
    canadian pharmacy reviews
    london drugs canada
    drugs without prescription
    canada pharmaceuticals online

  62. Your comment is awaiting moderation.

    Amazing advice. Thank you.
    http://www.canadianpharmacymsn.com/
    compare rx prices
    canadian cialis
    mexican pharmacy online medications
    canadian pharmacy online

  63. Your comment is awaiting moderation.

    You’ve made your position very nicely!!
    http://canadianpharmacyntx.com/
    best online pharmacy stores
    canadian pharmacy
    canadian pharmacy meds
    london drugs canada

  64. Your comment is awaiting moderation.

    Beneficial data. Thank you.
    http://canadianonlinepharmacynnm.com/
    canadian drug store
    canadian online pharmacies
    discount drugs online pharmacy
    canadian online pharmacies

  65. Your comment is awaiting moderation.

    Nicely put, Appreciate it!
    http://canadianpharmacysilo.com/
    ed meds online
    canadian pharmacies that ship to us
    canada pharmacies
    online pharmacies of canada

  66. Your comment is awaiting moderation.

    Cheers. I appreciate it!
    http://canadianpharmacyntx.com/
    online rx pharmacy
    canadian online pharmacies
    canada pharmacy no prescription
    north west pharmacy canada

  67. Your comment is awaiting moderation.

    Nicely put, Many thanks.
    http://canadianpharmaciescubarx.com/
    top rated canadian pharmacies online
    canadian pharmacies without an rx
    canada pharmacy online reviews
    canadian viagra

  68. Your comment is awaiting moderation.

    With thanks. I appreciate it!
    http://canadianonlinepharmacynnm.com/
    canadapharmacyonline com
    canadian pharmaceuticals online
    online canadian pharmacy
    aarp approved canadian online pharmacies

  69. Your comment is awaiting moderation.

    Great content. Thank you!
    http://www.canadianpharmacymsn.com/
    canada pharmacy online orders
    canada pharmaceutical online ordering
    canada pharmacy no prescription
    canada pharmacy

  70. Your comment is awaiting moderation.

    Terrific tips. Thanks.
    http://canadianpharmaciesnnm.com/
    canadian drugstore reviews
    northwest pharmacy
    drugs from canada
    canadian pharmacies that ship to us

  71. Your comment is awaiting moderation.

    Truly tons of useful knowledge.
    https://nicktambone.com/
    buy prescription drugs canada
    online pharmacies of canada
    prescription without a doctor’s prescription
    canadianpharmacy

  72. Your comment is awaiting moderation.

    Fantastic postings. Appreciate it.
    http://canadianpharmaciesnnm.com/
    cheap drugs online
    london drugs canada
    no prescription online pharmacy
    canada pharmacy

  73. Your comment is awaiting moderation.

    You said this very well.
    http://canadianpharmacymim.com/
    canadianpharmacy
    northwestpharmacy
    pharmacy tech
    canadian pharcharmy

  74. Your comment is awaiting moderation.

    Seriously a lot of terrific material.
    http://www.canadianpharmacymsn.com/
    canada pharmacies online
    canadian cialis
    no prescription pharmacies
    canada online pharmacies

  75. Your comment is awaiting moderation.

    Nicely put, Appreciate it!
    http://canadianpharmacymim.com/
    top rated online canadian pharmacies
    mexican pharmacies shipping to usa
    canada pharmacies online
    mexican pharmacies shipping to usa

  76. Your comment is awaiting moderation.

    You actually mentioned it well!
    http://www.canadianpharmacymsn.com/
    canadian pharmacy uk delivery
    top rated canadian pharmacies online
    drugs online
    canadian viagra

  77. Your comment is awaiting moderation.

    You actually reported this effectively!
    https://nicktambone.com/
    mexican pharmacies shipping to usa
    canadian pharmacies
    canadian pharmacy uk delivery
    canadian online pharmacy

  78. Your comment is awaiting moderation.

    Well expressed genuinely. .
    http://canadianpharmaciesnnm.com/
    pharmacy prices
    online pharmacies of canada
    canada pharmacies online
    northwestpharmacy

  79. Your comment is awaiting moderation.

    Good posts. Many thanks!
    http://canadianpharmacymim.com/
    pharmacy online
    canadianpharmacy
    get prescription online
    canada drugs

  80. Your comment is awaiting moderation.

    Amazing plenty of good advice.
    http://canadianpharmacymim.com/
    canadian pharmacy king
    top rated canadian pharmacies online
    pharmacy online mexico
    online pharmacies canada

  81. Your comment is awaiting moderation.

    Really many of amazing facts!
    http://canadianpharmaciescubarx.com/
    pharmacy prices
    canadian pharcharmy
    online pharmacy without a prescription
    canadian pharmacies without an rx

  82. Your comment is awaiting moderation.

    Terrific info. Regards!
    http://canadianpharmacymim.com/
    canadian pharmacy no prescription needed
    canadian pharmaceuticals online
    cheap prescription drugs
    global pharmacy canada

  83. Your comment is awaiting moderation.

    Thank you, Plenty of facts!

    http://canadianpharmaciescubarx.com/
    highest rated canadian pharmacies
    canada pharmaceuticals online
    top rated online canadian pharmacies
    canada pharmacy online

  84. Your comment is awaiting moderation.

    You mentioned that superbly!
    http://canadianpharmacyntx.com/
    buying drugs canada
    canadian pharmacy online
    pharmacy prices
    canadian pharmacies

  85. Your comment is awaiting moderation.

    Really a lot of valuable advice!
    http://canadianonlinepharmacynnm.com/
    canadian pharmacies online
    canada pharmaceuticals online
    best online pharmacy stores
    canada drugs online

  86. Your comment is awaiting moderation.

    Thanks a lot! Terrific stuff.
    http://canadianpharmacymim.com/
    pharmacies near me
    london drugs canada
    buy prescription drugs from canada
    london drugs canada

  87. Your comment is awaiting moderation.

    Many thanks! A lot of information.

    http://www.canadianpharmacymsn.com/
    prescription without a doctor’s prescription
    canada pharmaceuticals online
    best online canadian pharcharmy
    northwest pharmacy

  88. Your comment is awaiting moderation.

    Superb content. With thanks!
    http://canadianpharmacyntx.com
    onlinecanadianpharmacy.com
    north west pharmacy canada
    pharmacy cost comparison
    canadian drugs

Leave a Reply

Your email address will not be published. Required fields are marked *