|
Hello,
when reading a text file, the letters having accents, they appear square caps in a message box, how can we keep the same letters? thank you verry much.
|
|
|
|
|
its down to the encoding of the text, as far as i know you cant change that with the message box directly but maybe it can be set in the system
If only MySelf.Visible was more than just a getter...
A person can produce over 5 times there own body weight in excrement each year... please re-read your questions before posting
|
|
|
|
|
Hi,
Most probably the MessageBox is not at fault, the way you read your file is.
each text file uses some way to identify characters that are outside the regular ASCII character set
(which is less than 128 chars). You either use a "code page" telling what the byte values [128,255]
represent, or some more elaborate scheme such as UTF8 or Unicode, to get access to a much larger
character set where some or all characters use 2 bytes.
UTF8 and Unicode files start with a special byte sequence to identify them. When no byte sequence
is present, your best guess may be to use the code page that suits your locale; I typically use
new Encoding(1252) yielding a West-European code page.
So when reading a text file, you should apply the right "encoding" and pass that to your
input methods, e.g. File.ReadAllText Method (String, Encoding)
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Sunday, June 12, 2011 8:00 AM
|
|
|
|
|
Hello,
i encode the word file using this code :
Convert.ToBase64String(data) ,
but when i decode the code 64digits, we mus add an extention like .doc, can we know the extention of code base 64 digits? thank you verry mutch.
|
|
|
|
|
if it is a data file i think you would need to check the file header information and determine the filetype from that then choose you extension, this however would mean you need to have a list of file associations for different filetypes. You best option might be to store the extension somewhere before conversion if that is posible?
If only MySelf.Visible was more than just a getter...
A person can produce over 5 times there own body weight in excrement each year... please re-read your questions before posting
|
|
|
|
|
If I understand correctly, then no you can't. Encoding a word file (or any file) for that matter to base64 just stores the raw data of the file, not the name or extension or file data.
Regards,
Rob Philpott.
|
|
|
|
|
so we can't get the extension of the original file?? i don't like save the extension elonely in another filed, thank you verry mutch
|
|
|
|
|
Hi,
if you are creating an app that does Base64 file conversion, you have several options:
1. you could generate a file that has the original filename and append "64" to the extension;
2. you could generate a file that holds at least two strings, the first being the filename+extension,
the next one being the base64-encoded data.
BTW: I hope you are not reading all the data first, then turning that into a single (possibly huge) string. If you were to do so, a large word document (one that Word your barely manages to open on
your system) would not fit in your conversion app since that would have to hold both the original
and the converted data (which is 33% larger in size). The right way is to have a loop reading
say 64KB of data and outputting that in base64, then repeat until all is done.
[ADDED]
if you are storing binary file data in a database, I suggest you use two fields, one for the
filename, one for the data.
[/ADDED]
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Thursday, February 12, 2009 11:49 AM
modified on Sunday, June 12, 2011 8:01 AM
|
|
|
|
|
Hello,
i find an exemple to generate a word file, so i don't understand this code,
for (int i = 1; i <= Doc.Bookmarks.Count; i++)<br />
{<br />
object index = i;<br />
Microsoft.Office.Interop.Word.Bookmark bk = Doc.Bookmarks.get_Item(ref index);<br />
Bks.Add(bk.Name, bk.Range);<br />
}<br />
<br />
((Microsoft.Office.Interop.Word.Range)Bks[s]).InsertAfter(????);
in the model of my word file, it's name is MODEL.dot, they are thie sentence "test", but when i make this
((Microsoft.Office.Interop.Word.Range)Bks[s]).InsertAfter("test"); , there are an exception :
Object reference not set to an instance of an object.
Thank you verry mutch.
|
|
|
|
|
Hi,
I have added a category column to my Sharepoint document store. I want to create a web application that will allow users to search for documents based on the value of this category.
I have looked at the various articles here at CodeProject and I can't see anything that suits.
Can someone point me in the direction of how to achieve this in C#/ASP.NET?
Thanks
|
|
|
|
|
you may use the lists.asmx (webservice) from your sharepoint website.
Something like: in this article[^]
Also, you may use something like list.Attributes["CATEGORY_COLUMN"].Value to get the value for your custom column.
Calin
|
|
|
|
|
Hi,
I´d like to select DataRows with an Id and a Date, but I always get the following Error-Message:
Cannot perform '=' operation on System.DateTime and System.String.
Here my Code:
string BehID = data1.Behandlungen.Rows.Count.ToString();
string datum = microsim1["picdate"].ToString();
DataRow[] VerlaufDatum = data1.Verlauf.Select("BehandlungsID=" + BehID + " AND Datum= '" + datum + "'");
It worked perfectly witch Visual Studio 2003, but with Visual Studio 2008 I always get this Exception
thanks for your help.
|
|
|
|
|
im suprised it worked in any version
youor trying to compare a string to a dateTime which clearly is not the same type
As the BehID is unique why use the datum value at all?
If only MySelf.Visible was more than just a getter...
A person can produce over 5 times there own body weight in excrement each year... please re-read your questions before posting
|
|
|
|
|
Hi,
Try to create a DateTime object from
datum , to see if you have a valid data format in that string.
Calin
|
|
|
|
|
I already tried to create a DateTime Object from
datum
and the Cast worked perfectly, but there occurs the same Exception when I edit the Code as follows:
DataRow[] VerlaufDatum = data1.Verlauf.Select("BehandlungsID=" + BehID + " AND Datum= '" + Convert.ToDateTime(datum) + "'");
I think it has something to do with the '=' Operator, but I don´t know what´s wrong with it
|
|
|
|
|
Try by formatting the date and pass this string:
"#" + dt.Month + "/" + dt.Day + "/" + dt.Year + "#"
Calin
|
|
|
|
|
You need to convert one or both sides of your statement so that they are both the same data type. A string type and a datetime type are incompatible, so find a way to collect the datetime information contained in your string explicitly and use DateTime.Parse to make it compatible.
|
|
|
|
|
Also, you should try to format your date as following:
"#" + dt.Month + "/" + dt.Day + "/" + dt.Year + "#"
Calin
|
|
|
|
|
hey,
thanks a lot ))
that works fine and solves the problem perfectly!
|
|
|
|
|
I'm glad, no problem.
Calin
|
|
|
|
|
Ah, I love being reminded of Jet. Now we know where they DataSet team got there start.
Need custom software developed? I do C# development and consulting all over the United States.
If you don't ask questions the answers won't stand in your way.
Doing a job is like selecting a mule, you can't choose just the front half xor the back half so when you ask me to do a job don't expect me to do it half-assed.
|
|
|
|
|
This is more of a theoretical question that anything else. There is no way to simulate it(All results will differ from implementation to implementation) so here goes. What will be faster (The least amout of bytes). To download (Save) a file from a website or to open the file directly in the browser
Stephen Lintott Bsc IT (RAU)
|
|
|
|
|
Well if you download an image or open directly in browser you would still need to stream the image, so the byte count for the image atleast will always be the same. As far as i know whenever an image is viewed in the browser it is downloaded to computer anyway. So surely its the same process.... just my thoughts, i may be wrong
If only MySelf.Visible was more than just a getter...
A person can produce over 5 times there own body weight in excrement each year... please re-read your questions before posting
|
|
|
|
|
You're right.
If you save it, the byte stream will go to a place you have to assign. If you open it, you will save the picture in your cache. But if you want to open it I guess you also put it in your RAM, so I guess saving would be slightly quicker.
|
|
|
|
|
Thanks... its good to know i get things right sometimes
I was thinking there would be extra work in the loading but as the OP asked about displaying in a browser i assumed the intent was to show it to the end user in which case he would be displaying after download anyway... but as, like in most cases, the OP is AWOL we shall prob never know their aim lol
If only MySelf.Visible was more than just a getter...
A person can produce over 5 times there own body weight in excrement each year... please re-read your questions before posting
|
|
|
|