When i run the second form it occurs a error "The Process cannot access the file
C:\user\Maxs\Desktop\xml\Student.soap because it is being used by another process"
Can anybody fix this
Form1 Creating soap file
using System.IO;
using Students;// Student DLL file
using System.Runtime.Serialization.Formatters.Soap;
namespace TestAps
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Student s = new Student();
s.age = int.Parse(txtAge.Text);
s.name = txtUname.Text;
SoapFormatter sf = new SoapFormatter();
FileStream fs = new FileStream(@"C:\Users\Maxs\Desktop\XML\Student.soap",FileMode.OpenOrCreate,FileAccess.Write);
sf.Serialize(fs,s);
}}}
Form 2 Read Soap file
using System.IO;
using Students;// Student DLL file
using System.Runtime.Serialization.Formatters.Soap;
namespace TestAps
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Student s = new Student();
FileStream(@"C:\Users\Maxs\Desktop\XML\Student.bin",FileMode.Open,FileAccess.Read);
//s=(Student)bf.Deserialize(fs);
//BinaryFormatter bf = new BinaryFormatter();
SoapFormatter sf = new SoapFormatter();
FileStream fs = new FileStream(@"C:\Users\Maxs\Desktop\XML\Student.soap",FileMode.Open,FileAccess.Read);
s=(Student)sf.Deserialize(fs);
label1.Text=s.name;
label2.Text = Convert.ToString(s.age);
}
}
}