store user DATA

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • pei_world

    #1

    store user DATA

    hi
    I am new to C# programming. can anyone tell me what is the standard way to
    store high sensitive user data for application, so that application next run
    can get back those data.



  • Casey MacPherson \(msft\)

    #2
    Re: store user DATA

    Well that all depends on the tools available to you.

    You could store the data in a database (SQL server, Access etc...) you
    could store the data in a proprietary binary format. Databases are good for
    persistent data storage and usually have pretty good security and
    encryption.

    -Casey


    --
    Legal Disclaimer: just in case you were wondering:
    This posting is provided "AS IS" with no warranties, and confers no rights.

    "pei_world" <pei_world@hotm ail.com> wrote in message
    news:OW139MeuDH A.2340@TK2MSFTN GP12.phx.gbl...[color=blue]
    > hi
    > I am new to C# programming. can anyone tell me what is the standard way[/color]
    to[color=blue]
    > store high sensitive user data for application, so that application next[/color]
    run[color=blue]
    > can get back those data.
    >
    >
    >[/color]


    Comment

    • John Scalco

      #3
      Re: store user DATA

      You have a bunch of different ways.

      1. StreamReader and StreamWriter classes, allow you to read files.

      // create or open a file
      StreamWriter writer = new StreamWriter("c :\\test.txt");
      // write data to it
      writer.WriteLin e("File created using StreamWriter class.");
      // close
      writer.Close();

      similar class called StreamReader reads the file.

      Also you could create a class which derives from a persistent class,
      which then allows you to write that classes properties to disk.

      [Serializable]
      public class Dog {
      public string name;
      public string licenseTag;
      }

      Dog d = new Doc ();
      d.name = "Rex";
      d.tag = "OU812";

      IFormatter formatter = new BinaryFormatter ();
      Stream stm = new FileStream("myD ataStore.dta",
      FileMode.Create , FileAccess.Writ e,
      FileShare.None) ;
      formatter.Seria lize (stm,d); // stream the dog object out to disk.
      stm.Close();

      To read it back:
      ;IFormatter fmt = new BinaryFormatter ();
      Stream stm = new FileStream("myD ataStore.dta",
      FileMode.Open, FileAccess.Read ,
      FileShare.Read) ;
      Dog dogFromDisk = (Dog) fmt.Deserialize (stm);
      stm.Close();

      // the data has now been restored in the object
      //
      this will store the data in binary. If you need moer security then you could
      (just a wacky thought)
      after you write the object to disk, then encrypt it. When you load the
      object back into memory, then
      decrypt the file before loading the stream.

      With the file writina approach you could also encrypt it before you write it
      to file
      and then when you read the data back in, then once you have read it, then
      decrypt it maybe?

      of course, there are things like xml disconnected datasets and databases and
      all that, but my
      impression was you wanted to store some simple data say password or
      something like that in a file, which
      is in the same directory as the application or something like that. With
      that assumption, i think
      these approaches should get you up and running pretty quickly without the
      need for you
      to learn any of those other technologies... . but as I said it depends on
      your needs.

      hope that helps,
      J

      hope thi

      "pei_world" <pei_world@hotm ail.com> wrote in message
      news:OW139MeuDH A.2340@TK2MSFTN GP12.phx.gbl...[color=blue]
      > hi
      > I am new to C# programming. can anyone tell me what is the standard way[/color]
      to[color=blue]
      > store high sensitive user data for application, so that application next[/color]
      run[color=blue]
      > can get back those data.
      >
      >
      >[/color]


      Comment

      • John Scalco

        #4
        Re: store user DATA

        You have a bunch of different ways.

        1. StreamReader and StreamWriter classes, allow you to read files.

        // create or open a file
        StreamWriter writer = new StreamWriter("c :\\test.txt");
        // write data to it
        writer.WriteLin e("File created using StreamWriter class.");
        // close
        writer.Close();

        similar class called StreamReader reads the file.

        Also you could create a class which derives from a persistent class,
        which then allows you to write that classes properties to disk.

        [Serializable]
        public class Dog {
        public string name;
        public string licenseTag;
        }

        Dog d = new Doc ();
        d.name = "Rex";
        d.tag = "OU812";

        IFormatter formatter = new BinaryFormatter ();
        Stream stm = new FileStream("myD ataStore.dta",
        FileMode.Create , FileAccess.Writ e,
        FileShare.None) ;
        formatter.Seria lize (stm,d); // stream the dog object out to disk.
        stm.Close();

        To read it back:
        ;IFormatter fmt = new BinaryFormatter ();
        Stream stm = new FileStream("myD ataStore.dta",
        FileMode.Open, FileAccess.Read ,
        FileShare.Read) ;
        Dog dogFromDisk = (Dog) fmt.Deserialize (stm);
        stm.Close();

        // the data has now been restored in the object
        //
        this will store the data in binary. If you need moer security then you could
        (just a wacky thought)
        after you write the object to disk, then encrypt it. When you load the
        object back into memory, then
        decrypt the file before loading the stream.

        With the file writina approach you could also encrypt it before you write it
        to file
        and then when you read the data back in, then once you have read it, then
        decrypt it maybe?

        of course, there are things like xml disconnected datasets and databases and
        all that, but my
        impression was you wanted to store some simple data say password or
        something like that in a file, which
        is in the same directory as the application or something like that. With
        that assumption, i think
        these approaches should get you up and running pretty quickly without the
        need for you
        to learn any of those other technologies... . but as I said it depends on
        your needs.

        hope that helps,
        J

        hope thi

        "pei_world" <pei_world@hotm ail.com> wrote in message
        news:OW139MeuDH A.2340@TK2MSFTN GP12.phx.gbl...[color=blue]
        > hi
        > I am new to C# programming. can anyone tell me what is the standard way[/color]
        to[color=blue]
        > store high sensitive user data for application, so that application next[/color]
        run[color=blue]
        > can get back those data.
        >
        >
        >[/color]


        Comment

        Working...