473,320 Members | 2,202 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

unable to write a object in a file

when i am writting a class object in a data file the only char members are correct but the other data type variables are not in proper format in the data file.
pls help
Sep 6 '09 #1
1 1503
Banfa
9,065 Expert Mod 8TB
How do you know?

Are those other data members pointers? You can't write a pointer to a file (or rather you shouldn't). The next time you load the file you have no way of knowing if the same memory locations will be in use for the same thing. Also that is not the data of the object pointed to. You need to write the data of the object pointed to to the file.

It is not uncommon for each class in a hierarchy of classes that get written to a file to have a serialise method that writes (and reads) the class from the file. That way the container class can call the serialise method of the contained class at the correct time but the contained class can save (load) itself from file without having to expose private data.

Another option is to write file operator overloads for your classes so that you can open a file and use the << operator to write you class (and contained classes) but it amounts to pretty much the same thing (that is the method may be called in a slightly different manor but they would contain similar code).
Sep 6 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: lawrence | last post by:
I'm probably missing something obvious, but I'm unable to write a file with this function. I've used my FTP software to set permissions to 777 on all the files in question. I've tried r, r+, w, and...
0
by: Steve - DND | last post by:
We are continually receiving timeout, and "Unable to write data to the transport connection" errors while using the System.Net.HttpWebRequest class from an ASP.Net web page. Below are the two...
1
by: dina_vr | last post by:
Hi All, I am getting lot of System.IO.IOException: Unable to write data to the transport connection. exceptions when I write to a Stream which is connected to a Remote HTTPS server using a...
1
by: Joel Finkel | last post by:
Folks, I am unable to execute any ASPX files on a Windows 2000 Server, running as a Primary Domain Controller. The error is "Error BC31019: Unable to write to output file '<filename>'" By...
4
by: Rob Leyshon | last post by:
For whatever reason I am unable to use FileSystemObject e.g. using the code: Dim fso As New FileSystemObject Everytime my program hits this it gives the error: "Compile error: User-defined...
2
by: Seok Bee | last post by:
Dear Experts, In my web application, I am having a button to open a file located in the server. When I click on the button to view the file, I received the following error message:...
0
by: bazzer | last post by:
hey, im trying to access a microsoft access database from an ASP.NET web application in visual basic 2003.NET. i get the following error when i try running it: Server Error in...
0
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted...
3
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted...
1
by: =?Utf-8?B?U2NvdHQ=?= | last post by:
Hello, Using VS2008 in a C# web service application, a class has been created that inherits from the ConfigurationSelection. This class file has been placed in the App_Code folder. The...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.