Click here to Skip to main content
15,885,546 members
Articles / Desktop Programming / Windows Forms

FileSelect - Hassle Free Implementation of the File Menu

Rate me:
Please Sign up or sign in to vote.
4.67/5 (15 votes)
4 May 2009CPOL13 min read 51.1K   512   39  
A WinForms user control that implements the details of file handling commands for any document-centric application
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;

namespace PH.UI.FileSelect
{

  // simple document class for plain text, serving as an example
  public class TextDocument
  {
    private string m_data = String.Empty;

    public string Data
    {
      get { return m_data; }
      set { m_data = value; }
    }


    public void Save(string path)
    {
      System.IO.File.WriteAllText(path, Data);
    }

    public static TextDocument Load(string path)
    {
      string text = System.IO.File.ReadAllText(path);
      TextDocument doc = new TextDocument();
      doc.Data = text;
      return doc;
    }

    public static TextDocument New()
    {
      return new TextDocument();
    }
  }


}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Klippel
Germany Germany
Peter is tired of being called "Mr. Chen", even so certain individuals insist on it. No, he's not chinese.

Peter has seen lots of boxes you youngsters wouldn't even accept as calculators. He is proud of having visited the insides of a 16 Bit Machine.

In his spare time he ponders new ways of turning groceries into biohazards, or tries to coax South American officials to add some stamps to his passport.

Beyond these trivialities Peter works for Klippel[^], a small german company that wants to make mankind happier by selling them novel loudspeaker measurement equipment.


Where are you from?[^]



Please, if you are using one of my articles for anything, just leave me a comment. Seeing that this stuff is actually useful to someone is what keeps me posting and updating them.
Should you happen to not like it, tell me, too

Comments and Discussions