How do I embed meta data in a non-standard file? [closed] - c#

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 3 years ago.
Improve this question
I need to write code that receives firmware update files from various sources (nothing is a given, not even the file extensions) and passes them up to the cloud so that our software can download them to individual machines.
As part of the process, the front end needs to give the users a richer experience, so I need to include information such as the version number, last time there was an approved update to the file, and some other info about who is responsible for the update.
I've been directed to pass the data in as "meta-data" so that we don't have to include two files and at this point that doesn't seem like a very viable option. I've been researching meta data all day. TagLib is only for media files. I can use Microsoft API Code Pack to read some attributes but it won't let me write anything.
The shell32 option looks like the only other possibility but I can't figure out how to write to it. I'm using C# code in VS 2019, currently .NET framework 4.6.1 but we are about to upgrade to 4.8, I think.
Is there a practical way to write a string value as meta-data into a file without knowing anything more about the file than what I could discover with c#?

If you don't want to provide additional files or locations with the meta information you can create a new single file which contains your meta data and the actual firmware update. Think of it as a ZIP file where you have the firmware update file and some other file with the meta information. This way you will have only one file you can send around, but it has all the information you will need at any later point.
You cannot change the firmware update file in any way, specially if you don't know how the file format is. It would most likely break the firmware update.

Related

How to create file compare and copy program? [closed]

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 6 years ago.
Improve this question
I'm working on a project that needs to look at large amounts of data (~1TB) and copy it from drive A to drive B. It will be constantly run in the background (or tray) and run a check every XX hours/mins. At that time, it will check if there are any NEW files in drive A and copy them to drive B. If there are any files that were updated and newer then it will also copy and replace the files from A to B.
I'm not really sure where to start. Should I write this in Python or C# (maybe visual?)? If someone could give me some advice I would greatly appreciate it. Thanks!
EDIT:
Just wanted to give an update! I ended up using Robocopy, which is built into Windows. I moved away from Python and just created a small batch file that would check all of the files in drive A and compare to drive B. If anything was new or didn't exist, it copies it over. I then set up a task through Task Scheduler, also built into Windows. Works PERFECTLY in literally just 1 line of code in a batch file!
I was starting to look into building something like this myself. I was going to write it in c#, probably as a system service and then have it periodically scan for new files. It would then build checksums with either sha1 or md5. You can look here about how to generate an MD5 in c#. Here is some additional information talking about byte-for-byte vs checksum comparisons.
After it has its hash list, it can do a transfer of the files then do another hash on the destination to ensure it was written properly. I was going to just hang on to all the hashes and then when it rescans the directory it has something to compare to in order to see if a file was updated. Then it would just repeat the above.

executable file including a database [closed]

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
i wanted to create single executable file with c#
with my database and application.I wanted to install that application in client machine which have no internet. how can i include my database into my executable file (.exe) to let the user in client machine save and retrieve information.
thank you
This is simplest with single-file databases like SQLite. Create the database, pack it up with one of the compression APIs, then include the result as a resource in your application. On startup when the application fails to find the SQLite database file it can unpack it from the resource, save it to disk, then carry on. From that point the user is working on a copy of the database on disk and can make whatever changes they like.
If you're using a proper SQL server of some sort it's a bit more difficult, but essentially the same idea. Gather the data into a format you can work with, compress it and bind into a resource. On startup if the database doesn't exist you create it with whatever scripts or EF code you need, then unpack the resource and load all the data into the database.
Of course if your database is very large then you'll have a lot of bloat in your application. Better to pack the application and any data it needs as separate files in a ZIP or similar, then distribute the ZIP file. User unpacks the ZIP file and runs your application, which finds everything it needs sitting in the folder it was unpacked to.
Honestly, I'd go with the ZIP file option unless you have a really good reason not to.

How can I tell the difference between source and published .NET code? [closed]

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 9 years ago.
Improve this question
How can I tell the difference between source and published .NET code?
I am looking at some inherited code that I have not touched in about a year. The original designer had me first publish locally before uploading the published code to the internet server. Now I am looking a number of backed up source folders as well bas backed up published folders. I should have done a better job at naming the folders, I guess. Now I wonder: How can I tell the difference between source and published .NET code? Is there some easy way to see if some folder that contains only published code is lacking a file or xml setting?
As changes are made, they are published in the UI, so that means there should be some new files, or deleted files, and the directory tree may not be 100% the same. What you could do is download the deployed code to your local machine, and use a tool like Beyond Compare or some other directory comparer and let it determine the markup changes for you. There are several tools that do a good job for this.
That would give you an idea of the difference between files, but won't parse DLL's. That you would have to use a tool like reflector or Telerik's JustDecompile to compare the code, but I really wouldn't go that far, but you could.

Implementing a application HTML help system [closed]

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 5 years ago.
Improve this question
We want to implement a application help and documentation system. It should be based on HTML, because there are a lot of existing files and it gives us the most flexibility. Currently we use CHM files. We want to enable internal people (not developers) to edit the contents.
We thought of a stand-alone application that supports TOC, indexing (tags), search, etc. We also thought of using a local web server.
Until now our application uses pure C#, it would be good to keep this.
We are totally clean of web/asp knowledge, so the question is:
Where is a good place to start?
You can use documentation apps like SandCastle
Which use your XML documentation in your code to generate a help file.
Finally we ended up implementing a local HTTP server:
Internal people creates HTML content within our internal network
Our own build-tool creates the TOC and a search index and packs all content to a zipped file
The zipped file is packed into the application installation
When the end-user call help from within our application, the local http server is started
The HTTP server uses the HttpListener class
With this, it is possible to have some HTTP queries for special tasks like starting tools of our application by clicking a link without interception of the browser

Without using database how Can I Search for a word and display it's related content in another field [closed]

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 6 months ago.
Improve this question
So the question can be reformatted as "What can replace a database in an offline version?"
The initial idea is inspired from wordweb where you just type the word and then you get the meaning of it displayed in a fraction.
Of-course they are not saving all the words and there meanings in a database. What are they using? Are they storing all the values in a file and retrieving the corresponding meaning?
Is there any article which shows the above approach(Reading a particular section of a file ).
Are they using HashTables or similar?
You could utilize a local database such as SQLite or you could utilize a text file and store your data in it.
I suggest you to use an embedded database to store words and meanings. Try to look at Sqlite. It's simple to use, just require to include a dll in your setup, and has a wrapper to use it from c#.
It is very stable ,fast and widely used.
I don't know what it is they are using, but there is at least SQLite, a database engine that doesn't require installing any server or other program, since it gets compiled into your executable and uses a single file for the database. That's as close as you'll get to an actual database with nothing but filesystem access.
Otherwise, if the amount of data isn't too large, you could store it in a file format that isn't too hard to parse (such as XML, although the overhead is considerable), load all your data into memory, and then use .NETs built-in DataSet functionality, or better yet, Linq to objects or Linq to datasets to manipulate the data.

Categories

Resources