Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
If i have a class that contains some string, int and List type properties and I want to store that class object into my physical disc. So, which method is better performance wise and file size wise.
There is no correct answer really. Performance-wise the binary method is faster and the file size will be smaller, XML well be slower to parse and will have a bigger size because of it adds "metadata" to describe things.
But it really a question of application, the XML is human-readable and more universal while the binary format depends on your implementation of it and cannot be read by others if they don't have your program/specification for this file (unless of course they reverse engineer it...)
Also binary format gives you more freedom in a matter of compression/encryption etc...
I agree with Jonathon and Urilil.
While binary is more efficient for performance and file size, I would not recommend to use it.
You will face two issues :
- i case of a bug, how do you know if the bug is in the write or in the read side ?
- when your class evolves (and it will), you might not be able to read old files whith last version of your application
So, use XML or JSON.
if you still need binary, have a look at protocol buffers
It actually depends on the context. If you have two applications using same data, you might use Binary Serialization which is faster but less flexible. But in case of different systems, like one in C# another in Python, XML serialization is more appropriate for its flexibility. And you have to keep performance issues in mind. So, there is always a tradeoff.
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 1 year ago.
Improve this question
How I can save a level in player's data when player complete level and go to next level or when player quite the game. Thank you!
There are many, many different ways to accomplish this. Since your question is so broad, I can only offer broad answers for you to start your research, in rough order of complexity.
PlayerPrefs: If you have a very limited amount of save data, perhaps 5-10 data points, this is a convenient library provided by Unity to set and get strings, ints, and bools. It operates differently on each platform, but "just works" for the most part.
Writing to Files: If you have more data than should be saved using PlayerPrefs, or you'd like your files to be editable/readable/transferrable by your players (or you, during development, since PlayerPrefs writes to the underlying store in binary format, typically), you can do this. Google up "reading and writing files C#" for tutorials and APIs on how to do this. You can also obfuscate these files by encrypting/decrypting them, but you'll need to be aware that converting them to a binary format has security implications, so don't go down this route (encrypting) until you know what you're doing.
Writing to [remote] databases: If you have a great deal of data (images, audio, gigs of text), then a database might be an option for you. That's very much beyond the scope of this question, however, but you should know that it's relatively easy to do this with C#.
There are other esoteric solutions, obviously, but that should get you started.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I am trying to store a software "Calender"(complex logs that saved and browsed based on date).
I tried using both .ini and xml but when the application tried to read the entire file to find info for 1 specific day out of the 100 days (or so it seemed), it took almost 9 seconds to get 5 variables out of 500 variables. The size of the actual file might eventually be more than 40 variables per day.
Also, I would rather not make a file for each day, that will seems a little bit unprofessional and messy.
I am asking the question to know if there is an alternative to keep things fast and neat. The data includes different types of variables and different amounts of them. I know i am kinda overdoing it with logging thing but the program needs logs to do its work
If the data must be stored it has to be a file or a database (local or remote), I'd go for SQLite, it would end in a single file, but you could query the data with SELECT, JOIN, etc.
EDIT:
You can use SQLite3 from c# if you include this package:
https://www.nuget.org/packages/System.Data.SQLite/
You'll need to learn some SQL, but after that you'll just use something like:
select Message from Logs where Date > '2015-11-01' and Date < '2015-11-25';
which is easier, faster and clearer than messing with XML, and it will not load the whole file.
As mentioned above, SQLite will offer a great possibility. Since you (generally), and probably not a lot of people out here will be able to write a database management system that is as efficient as the ones out there.
https://www.sqlite.org
Whole point of using RDBMS because it's far more efficient that dealing with files.
SQL Lite is light weight and easier to deploy. But remember that,
SQLite only supports a single writer at a time (meaning the execution
of an individual transaction). SQLite locks the entire database when
it needs a lock (either read or write) and only one writer can hold a
write lock at a time. Due to its speed this actually isn't a problem
for low to moderate size applications, but if you have a higher volume
of writes (hundreds per second) then it could become a bottleneck.
Reference this question
If this is an enterprise level application requirement I would go for Azure Table storage based solution which is identical for this sort of scenario.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
Disclaimer: Yes, I am fairly new to storing data in files. But this is something I'm willing to learn, and take the time to learn
I am working on creating a program for someone who keeps track of volunteers and how much time they spend working, and what they are working on.
For each volunteer I will have their Address Information, email, phone, etc. I will also have what show they worked, how long they worked it for, and what position they were working.
Later, the user will be able to access a way to print out monthly reports of this information.
I am wondering if anyone is willing to give me a nudge in the right direction. How should I store all this data? I've heard of XML, SQL, JSON, and other things here and there. I need something that can handle large amounts of data, as there are about 200 volunteers right now, and data will need to be constantly added to this file(s). Are there any suggestions? If you need me to clarify something, please just ask.
Also, I am using Windows Forms Application, C#.
There are different ways to accomplish this, most preferred ones would be either SQL database (MySQL, MSSQL, SQLite, etc.), JSON storage (and GZipping, for good measures. Saving storage, you know), or binary storage (aka. knowing the complete size of the data you're storing, such as how many Int32's, and reading this in bytes from a file).
I'd go with the JSON storage if you're not planning on accessing this data from more than 1 computer.
If portability is what you want, you're gonna want to go with SQL.
If you're just looking for a simple way to store data, then it'd be either JSON or binary saving.
These are probably the best choices you have, on how to save data.
#Edit: Seeing how you've specified large amounts of data, your best shot would be either SQL or Binary. Binary, because you can jump around in files because you know the size of each object, so you wont have to read all of them. SQL because it has this feature built as part of the core. Json simply wont be a very good choice for large amounts of data.
XML, you're gonna want to avoid entirely, unless you want to be able to export data because other applications requires it in XML format. XML simply uses too large amounts of storage space, due to the whole structure of the language.
#Edit2: Would whoever downvoted my answer, explain why please? .__.'
SQL can handle pretty much a lot of data. It is easy to use for a beginner and there is a lot of support for it.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I create two projects using dot net. I send some data from one project to another project. I already handled this using xml conversion. Now I think to convert this using json data. Which one is best?.
In most cases, json is better. Because it has less redundant text and more efficient to parse. And what's more, is's much easier to parse json in javascript so that building a web app is much more convenient.
On the other hand, XML is more readable than json. That might be the only advantage of XML in this case.
XML is more verbose, but in the other hand is pretty easy to read.
JSON is simpler but not so good to read.
If you will not have humans looking the data, maybe using JSON would be a better idea. Since its smaller and will be less of a burden in your network (If that is a problem).
The other way you could evaluate, is looking on serialization speed, and that will depend a lot on the library you are using.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
Is it possible to convert an AVI file to 3gp in C# ? If so how could I do this? Any ideas will be appreciated, thanks in advance.
It depends what you mean by "convert". Both 3GP and AVI are wrapper formats, so are you merely trying to change the container format, or do you want to re-encode the streams as well?
Either way, you should probably take a look at ffmpeg (Windows info). For simple cases (i.e. you have the file, want a single output file), you should probably consider it invoking it on the command-line (i.e. System.Diagnostics.Process), which is much easier (and doesn't involve any licensing issues). If you want to access libavcodec/libavormat programatically, I highly recommend skipping any .NET wrapper libs (they all are in different states of sucking; Tao being the best but that's not saying much) and instead writing a C++/CLI wrapper. I started doing this, and once I got my head around data marshalling, etc., and figured out how to build it (Part 1, Part 2), it wasn't too hard.
There is no really easy way to do it; my advice is to use ffmpeg, either through the use of a C# wrapper of by calling it externally. There seem to be several C# wrappers for ffmpeg (like this one) but they all seem to be in various stages of development and not really usable. Your only option is likely going to be by calling it externally.