Video tutorial shows on how to read and write to a text file using StreamReader and StreamWriter in C# Visual Studio 2008. Click here to get more about Csharp Tutorial
Showing posts with label C#. Show all posts
Showing posts with label C#. Show all posts
C# - Read and Write XML Database File
Video tutorial on how to make a program that read and write an advanced xml (eXtensible Markup Language) database. Click here to learn more about Csharp Tutorial with free project ready to download provided.
.
Sample code to write xml.
string sStartupPath = Application.StartupPath; XmlTextWriter objXmlTextWriter = new XmlTextWriter(sStartupPath + @"\myfile.xml",null); objXmlTextWriter.WriteStartElement("MySelectedValues"); objXmlTextWriter.WriteStartElement("ID1"); objXmlTextWriter.WriteString(string); objXmlTextWriter.WriteEndElement(); objXmlTextWriter.WriteStartElement("ID2"); objXmlTextWriter.WriteString(string); objXmlTextWriter.WriteEndElement(); objXmlTextWriter.WriteEndElement(); objXmlTextWriter.Flush(); objXmlTextWriter.Close();
and for the read part:
doca = new XPathDocument(Application.StartupPath + @"\myfile.xml");
nav = doca.CreateNavigator();
expr = nav.Compile("/MySelectedValues");
iterator = nav.Select(expr);
while(iterator.MoveNext())
{
XPathNavigator nav2 = iterator.Current.Clone();
nav2.MoveToFirstChild();
string s1 = nav2.Value.ToString();
nav2.MoveToNext()
string s2 = nav2.Value.ToString;
}
.
Sample code to write xml.
string sStartupPath = Application.StartupPath; XmlTextWriter objXmlTextWriter = new XmlTextWriter(sStartupPath + @"\myfile.xml",null); objXmlTextWriter.WriteStartElement("MySelectedValues"); objXmlTextWriter.WriteStartElement("ID1"); objXmlTextWriter.WriteString(string); objXmlTextWriter.WriteEndElement(); objXmlTextWriter.WriteStartElement("ID2"); objXmlTextWriter.WriteString(string); objXmlTextWriter.WriteEndElement(); objXmlTextWriter.WriteEndElement(); objXmlTextWriter.Flush(); objXmlTextWriter.Close();
and for the read part:
doca = new XPathDocument(Application.StartupPath + @"\myfile.xml");
nav = doca.CreateNavigator();
expr = nav.Compile("/MySelectedValues");
iterator = nav.Select(expr);
while(iterator.MoveNext())
{
XPathNavigator nav2 = iterator.Current.Clone();
nav2.MoveToFirstChild();
string s1 = nav2.Value.ToString();
nav2.MoveToNext()
string s2 = nav2.Value.ToString;
}
Labels:
C#
C# - Load XML File to DatagridView
This video tutorial shows how to load a xml file into a datagridview using the C# programming language. Click here to learn more about Csharp Tutorial with free project ready to download provided.
Labels:
C#
C# - Create Simple Project Login Form
This video tutorial shows on how to create a log-in form, validate user name with a valid password and how to use the If then else statement. Click here to learn more about Csharp Tutorial with free project ready to download provided.
Labels:
C#
C# - Using Integers
This video shows how to code an array of integers using C# and Visual Studio 2008 Express Edition. Click here to learn more about Csharp Tutorial with free project ready to download provided.
Labels:
C#
C# - Static Class or Object, Implications of Programming Static Data
This video tutorial shows the concept of static class or object, and shows the implications of programming static data, using C# and Visual Studio. Click here to learn more about Csharp Tutorial with free project ready to download provided.
Labels:
C#
C# - Objects, Instances, Method Passing, Plus Getters and Setters
This video continues the study of objects, instances, method passing, plus getters and setters, using Visual Studio 2008 and C#. Click here to learn more about Csharp Tutorial with free project ready to download provided.
Labels:
C#
C# - Encapsulation, Message Passing and Attributes
This video introduces the concepts of encapsulation, message passing, plus attributes in the context of getters. Click here to learn more about Csharp Tutorial with free project ready to download provided.
Labels:
C#
C# - Memory Allocation
This video explains the mechanics of memory allocation in the context of objects and classes. This is a freshman-level lecture, using Visual Studio 2008 and C#. Click here to learn more about Csharp Tutorial with free project ready to download provided.
Labels:
C#
C#, C Sharp - Classes, Objects in Java and C++
This video explains the concept of Class and Object to Freshmen in CS and EE. Click here to learn more about Csharp Tutorial with free project ready to download provided.
Labels:
C#