I want to retrieve the user name and the password from a .ser (Java Serialized Objects) file in
C# which I am saving into when I am creating a user.
ArrayList spnavn;
spnavn = FileController.ReadFile(Server.MapPath
("~/App_Data/MinPlayers.ser"));
Application.Set("Players", spnavn);
The user also has values like ID and such, but i only want to get the name and the password out, so the user can be able to use these as a login.
Can I do .getName or .getpassword in some way to get it out from the file? Or any other solutions ?
Basically I'm creating some users, via a webmasterpage and putting them into a file called MinPlayers.ser. So I want to get information out of it again, but the only information I want is the Name and Password which will be used in the loginform in my frontpage
public class FileController
{
public static void Writefile(ArrayList a, string filnavn)
{
FileStream fs = new FileStream(filnavn, FileMode.Create,
FileAccess.Write, FileShare.None);
BinaryFormatter bf = new BinaryFormatter();
bf.Serialize(fs, a); // tag vores object, lav til binary
string, og smid den videre
fs.Close();
}
public static ArrayList ReadFile(string filnavn)
{
FileStream fs = new FileStream(filnavn, FileMode.Open,
FileAccess.Read);
BinaryFormatter bf = new BinaryFormatter();
ArrayList a = (ArrayList)bf.Deserialize(fs);
fs.Close();
return a;
}
}
http://msdn.microsoft.com/en-us/library/e474a3yk.aspx
if you take a look at the link I posted: I want to forexample get customerAddress.Region and customerAddress.City out of the file instead of the WHOLE string with all values if you understand?
customerAddress.Street = "1111 White Street";
customerAddress.City = "Sturtevant";
customerAddress.Region = "WI";
customerAddress.PostalCode = "53177";
customerAddress.CacheAddress();