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. Saving text file with StreamWriter

Saving text file with StreamWriter

Scheduled Pinned Locked Moved C#
csshelp
6 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.
  • M Offline
    M Offline
    Mark F
    wrote on last edited by
    #1

    Anytime I open or save a .css file using RichTextBox.LoadFile() or .SaveFile() methods Frontpage opens the file. So I write the contents to disk using the following. Even so, Frontpage still tries to open the file!

    try
    {
    using (StreamWriter writer = File.CreateText(path))
    {
    foreach (string line in rich.Lines)
    writer.WriteLine(line);
    }
    }
    catch (IOException e)
    {
    // error handling here
    }

    Mark

    P G 2 Replies Last reply
    0
    • M Mark F

      Anytime I open or save a .css file using RichTextBox.LoadFile() or .SaveFile() methods Frontpage opens the file. So I write the contents to disk using the following. Even so, Frontpage still tries to open the file!

      try
      {
      using (StreamWriter writer = File.CreateText(path))
      {
      foreach (string line in rich.Lines)
      writer.WriteLine(line);
      }
      }
      catch (IOException e)
      {
      // error handling here
      }

      Mark

      P Offline
      P Offline
      PIEBALDconsult
      wrote on last edited by
      #2

      Huh, bummer.

      1 Reply Last reply
      0
      • M Mark F

        Anytime I open or save a .css file using RichTextBox.LoadFile() or .SaveFile() methods Frontpage opens the file. So I write the contents to disk using the following. Even so, Frontpage still tries to open the file!

        try
        {
        using (StreamWriter writer = File.CreateText(path))
        {
        foreach (string line in rich.Lines)
        writer.WriteLine(line);
        }
        }
        catch (IOException e)
        {
        // error handling here
        }

        Mark

        G Offline
        G Offline
        Guffa
        wrote on last edited by
        #3

        If you have the web site open in Frontpage it will watch for file changes. It doesn't matter how you write the file, you can't change it without changing it...

        Despite everything, the person most likely to be fooling you next is yourself.

        M 1 Reply Last reply
        0
        • G Guffa

          If you have the web site open in Frontpage it will watch for file changes. It doesn't matter how you write the file, you can't change it without changing it...

          Despite everything, the person most likely to be fooling you next is yourself.

          M Offline
          M Offline
          Mark F
          wrote on last edited by
          #4

          Frontpage is not running, and I am simply editing a .css document (text) in a RichTextBox. I doesn't make any sense that Frontpage opens after the file is saved in the RichTextBox control! Mark

          G 1 Reply Last reply
          0
          • M Mark F

            Frontpage is not running, and I am simply editing a .css document (text) in a RichTextBox. I doesn't make any sense that Frontpage opens after the file is saved in the RichTextBox control! Mark

            G Offline
            G Offline
            Guffa
            wrote on last edited by
            #5

            No, that doesn't make sense. Applications doesn't start by themselves, so it seems that you start the css file somehow, causing Frontpage to open... Do you do anything more when loading or saving the file? I suppose that you create the css file for some reason, so what do you do with it?

            Despite everything, the person most likely to be fooling you next is yourself.

            M 1 Reply Last reply
            0
            • G Guffa

              No, that doesn't make sense. Applications doesn't start by themselves, so it seems that you start the css file somehow, causing Frontpage to open... Do you do anything more when loading or saving the file? I suppose that you create the css file for some reason, so what do you do with it?

              Despite everything, the person most likely to be fooling you next is yourself.

              M Offline
              M Offline
              Mark F
              wrote on last edited by
              #6

              After the text file was saved a webbrowser control attempted to navigate to the local document path. Since it's css Frontpage opened the file by default. This error was not readily apparent at first. >>>>>>>> :doh: Mark

              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