net generator

net generator

  • NA
  • 6
  • 2.2k

FileSystem.FilePutObject Alternative

Jun 15 2018 3:36 AM
Hi
I converted vb6 code into C# but facing an error.
Suppose we have Person 
--------------------------------------------
 
public class Person
{
private int intID;
private string strName;
private string strSurname;
public Person()
{
intID = -1;
strName = "";
strSurname = "";
}
public int ID
{
get
{
return intID;
}
set
{
intID = value;
}
}
public string Name
{
get
{
return strName;
}
set
{
strName = value;
}
}
public string Surname
{
get
{
return strSurname;
}
set
{
strSurname = value;
}
}
}
 --------------------------------------------------------------------
I want to write this class into file. I was using 
Person entP = new Person();
entP.ID = 1;
entP.Name= "john";
entP.Surname ="doe";
FileSystem.FileOpen(1, "test_file", OpenMode.Binary);
FileSystem.FilePutObject(1, entP,-1);
FileSystem.FileClose(1);
But it throws an error
Unhandled Exception: System.ArgumentException: File I/O with type 'Person' is not valid.
It seems FilePutObject does not support classes. Is there alternative way to do same task?
Please guide
thanks