Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to Clear Contents of a NotePad Textfile

How to Clear Contents of a NotePad Textfile

Scheduled Pinned Locked Moved C#
questioncsharptutorial
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    zoroyster
    wrote on last edited by
    #1

    Hi. This is sorta no brainer question for some of you, but does anyone know the C# codes to clear all contents of a certain notepad file? thanks a bunch

    K 1 Reply Last reply
    0
    • Z zoroyster

      Hi. This is sorta no brainer question for some of you, but does anyone know the C# codes to clear all contents of a certain notepad file? thanks a bunch

      K Offline
      K Offline
      Keshav V Kamat 0
      wrote on last edited by
      #2

      one way would be to use a streamWriter object and clear all the contents of the file and close the same.

      Keshav Kamat :) India

      X 1 Reply Last reply
      0
      • K Keshav V Kamat 0

        one way would be to use a streamWriter object and clear all the contents of the file and close the same.

        Keshav Kamat :) India

        X Offline
        X Offline
        xibeifeijian
        wrote on last edited by
        #3

        Try this please:-> using System.IO; FileStream fs=new System.IO.FileStream(yourTxtFilePath,FileMode.Create); fs.Close();

        :^):^):^):^):^):^):^):^):^):^):^):^) :^):rose::rose::rose::rose::rose:▒▒〓▒〓▒▒ :^):rose::^):^):^):^)▒〓〓〓〓〓▒ :^):rose::^):^):^):^)▒▒〓▒〓▒▒ :^):rose::^):^):^):^)▒〓〓〓〓〓▒ :^):rose::rose::rose::rose::rose:▒▒〓▒〓▒▒ :^):^):^):^):^):^):^):^):^):^):^):^)

        Z 1 Reply Last reply
        0
        • X xibeifeijian

          Try this please:-> using System.IO; FileStream fs=new System.IO.FileStream(yourTxtFilePath,FileMode.Create); fs.Close();

          :^):^):^):^):^):^):^):^):^):^):^):^) :^):rose::rose::rose::rose::rose:▒▒〓▒〓▒▒ :^):rose::^):^):^):^)▒〓〓〓〓〓▒ :^):rose::^):^):^):^)▒▒〓▒〓▒▒ :^):rose::^):^):^):^)▒〓〓〓〓〓▒ :^):rose::rose::rose::rose::rose:▒▒〓▒〓▒▒ :^):^):^):^):^):^):^):^):^):^):^):^)

          Z Offline
          Z Offline
          zoroyster
          wrote on last edited by
          #4

          xibeifeijian ,code works perfectly! thanks alot xibeifeijian and Keshav!!

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups