It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I'm sorry but it seems a very silly question, but if i have a format let it be .epub for example and want to build a class (C# class) that can read it, what should I do. I'm not talking about a certain format or certain language, but I'm asking about building an interface that can read/write this format. vaguely I guess COM object should do this but i haven't dealt with them and get tired of learning any concepts and technology to find that it is irrelevant to my needs. thank you in advance and sorry for this very loose. question
If you know the format of the file then the only specific thing you need to do is create a class that will read/write that format. The internal structure of the class can be represented however you want.
To write the format just use System.IO.FileStream and/or System.IO.StreamWriter. If the file is represented in hex data then use a BinaryReader or BinaryWriter.
The process of reading/writing a file is then just a matter of parsing the data into your internal representation in code, when reading, so you can edit it and then writing out the data according to the file format spec.
Here is a link on file formats just in case. If you have a more specific question ask it and you can get more specific help and/or examples.
EDIT:
If you are looking for the EPUB spec it is Here. I'm afraid that you are going to have to read the spec for any file format that you plan on creating a class for, which can be tedious. I had to do this for PDF documents recently. Just make sure you can understand the spec, look at examples and try different things out when writing/reading. This is really the only thing you can do.
Related
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
Am using Microsoft.ACE.OleDb to write data to excel. I want to format the worksheet by using Microsoft.ACE.OleDb only? My requirement is i dont want to use 3rd party libraries like Microsoft.InterOp and EPPlus. How can i do this?
No, you can't. Microsoft.ACE.OleDb allows you to operate data, not to format cells and text
If you don't want to use Interop.Excel, you should look at Late binding
The only reliable way to create a real Excel worksheet with formatting is using Aspose.Cells for .NET.
There also is ExcelPackagePlus on CodePlex, which is opensource, but it has a bug that prevents reading or writing workseets when your text contains a www/mail-Link that is invalid, e.g. a password that contains an # sign, with excel incorrectly interpreting this as a link.
There is also carlosag.excelwriter, but it doesn't really create an excel file, it creates an XML file that can be read and displayed by excel.
Excel 2010 however issues a warning, "Not a valid excel file", that may potentially scare off users.
I would not recommend using ACE.OleDb, you will run into 32/64 bit issues, as the ACE drivers are already on life-support and deprecated and thus not available on 64 bit windows (matters if you have 64 bit excel as well).
For the same reason, I would not use Interop.Excel.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I am attempting to write a local set of wrapper classes into our institution API (I work at a post secondary institution). The purpose of these classes are to securely pull transcripts from a remote service, and to allow the abstraction away from how that service works to our programmers. How the service works is confidential however the question I need an answer too is this:
How to deal with this when each transcript response comes in a different xml format depending on which of the schools it comes from. There are over 30.
As an example: Institution A has the tag, at the top of the document near the root, for GPA of a student to be |GPA|4.0|/GPA| whereas another institution might have it in a completely different part of the XML, near the bottom and perhaps 3 children deep, and name the tag |GradePointAverage|4.0|/GradePointAverage| (Pretend | is xml angle brackets)
Any suggestions how to deal with this lack of standardization?
It sounds like you should aim for one common data model, and then 30 different classes which are able to deserialize from XML to that data model. Depending on exactly how different they are, there may be significant aspects of reuse, and you may even be able to parameterize some differences. Using LINQ to XML makes it reasonably easy to parse any one format.
I would aim for lots of simple code rather than a small amount of "clever" code: parsing each individual format should be reasonably straightforward, and hopefully easy to test. Yes, it'll be tedious to write this code, but it should end up being easy to follow, and easy to add more formats if you need to.
You could use XSLT to perform a transformation into a single format of course, but personally I'd rather write C# :)
This assumes you can create a common data model - if the formats are very different, you may find that you can't accurately represent the data in each file without having a horrible lowest-common-denominator. Coming up with a good data model is likely to be as hard as writing each individual parser.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I am writing a C# asp.net web application that receives CV's in various formats i.e. doc, docx, pdf, text, etc.
I was wondering if there was a simple way I could remove certain information from the document not matter what file type it is and then pass on the edited file to the end user?
The information to be removed will be held in a string
You will need to parse each file type using separate APIs.
.docx can be parsed using: http://docx.codeplex.com/
.pdf can be parsed using: http://www.pdfsharp.net/
etc.
If you use a streamreader (http://msdn.microsoft.com/en-us/library/system.io.streamreader.aspx) to read through the document, you could use the ReadToEnd function to store everything in a string, then use the function:
MyString.Replace("Something to replace", "");
to remove the matches. If the file formats cannot be read in as a string, you'll have to consider different options. However, there are likely faster solutions given the file formats, and it's likely not stored as simply.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I have written a program in .net C# to encrypt some information.
To accomplish the task I used an array which contains confidential information.I need to know that is it possible to crack the exe.I mean can anybody get the array from the exe file.The array values are not shown in the application.I used community version of Dotfuscator which comes with Visual Studio.NET.
All I want to know that is it possible to extract the exe to access the member variables used in it.. ??
Yes, it would be very easy to decompile the application. You might want to install and run Reflector (or a similar equivalent) and see what gets exposed. Fundamentally, if there's sensitive information embedded in the application, it can always be found.
Definitely yes, if you didn't encrypt the Exe by using Dotfuscator or any other protection software, the cracker not just can see your array variables, but can return the whole source code of your application.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 12 years ago.
i read a zip file in my application and i don't want to extract after i read it all ..
i want to extract it while i am reading it.
so how do i extract stream of bytes for a file while i am reading it ?
The GZipStream and DeflateStream classes are wrappers around a normal Stream object. This means that you can extract the data as you're going along before a) the whole file has been downloaded and b) without loading all of the data in to memory.
These are available in .NET 4 upwards, otherwise you'll need to use #ZipLib as suggested.
EDIT:
After looking around it would appear that #ZipLib is definitely the way forwards with this. The same principles apply to these classes in that they are streams, they can work as the file is being downloaded or read over a network and they don't require the whole file to be in memory. I'm currently using it in a project to open zip files from an http server, so I've seen it in action!
The .NET Base Class Library doesn't include classes to stream .zip files. Take a look at SharpZipLib.
Here are various examples of compression/decompression using the #Zip library.
http://wiki.sharpdevelop.net/SharpZipLib-Zip-Samples.ashx