Home All Groups Group Topic Archive Search About
Author
19 Nov 2004 12:49 AM
ALI-R
have tree variable with their values:

1) rptName="report1"
2) rptPath="c:\......"
3) serverPath=http://server...
and
4)an arry which contain Name/value pairs.

what is the best way of wrting them into an xml file(C#)??
these Xml files are stored in the same directory so I also give the XML file
a uniqe name so I can make sure that it dosn't overrite the other file.


thanks for your help.
ALI

Author
19 Nov 2004 7:19 AM
Victor Hadianto
> what is the best way of wrting them into an xml file(C#)??
> these Xml files are stored in the same directory so I also give the XML
> file
> a uniqe name so I can make sure that it dosn't overrite the other file.

You can do a simple Object -> XML file serialisation, ie:

string fileName = "fileName.xml";

XmlSerializer x = new XmlSerializer(this.GetType());

using (TextWriter writer = new StreamWriter(fileName))

{

x.Serialize(writer, this);

writer.Flush();

}

That will create an XML file of your object with the name fileName.xml

About creating a unique name, if your object has a unique ID use that one.
If you want to store it sequentially you need to somehow persist the last ID
that you use or scan the directory everytime your app starts up. Another
idea is to use the current date date time.

Show quote
"ALI-R" <new***@microsoft.com> wrote in message
news:u2JtaIdzEHA.2624@TK2MSFTNGP11.phx.gbl...
> have tree variable with their values:
>
> 1) rptName="report1"
> 2) rptPath="c:\......"
> 3) serverPath=http://server...
> and
> 4)an arry which contain Name/value pairs.
>
>
>
> thanks for your help.
> ALI
>
>
>

AddThis Social Bookmark Button