|
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
|
|
|
|
|
Deresen wrote: But if you want to open it I guess you also put it in your RAM
No, it won't, since there is no telling how big the file is and it could run the system out of memory, the file is written directly to disk, then the file is launched using the Shell.
...and the OP didn't say anything about a picture, but listed generically, "file".
|
|
|
|
|
That's true.
And we assume it is a file.
The file has to be downloaded, always, if you save it or if you show it.
But if you show the file, the computer has to write the bits to the screen. This will cost time and possible more data which will stream to the ram.
|
|
|
|
|
There's no difference between the two processes. The file is downloaded into the browser cache either way.
|
|
|
|
|
Hi,
save=download+writeToFile
open=download+writeToScreen
Now what is faster depends on the complexity of the data. If it is simple HTML and a modern PC, showing it would typically be faster than writing it to disk; OTOH if it is a complex Excel file with lots of start-up macro's clearly writing to file would be faster since it does not require launching the app nor interpreting/executing the data.
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:01 AM
|
|
|
|
|
Ok I get what your saying. But I did an experement with eathereal and saw that if you copy the file from a file server there is more chater on the network than if you open the file. I'm just wondering if the same applies to a download or open over the net.
Stephen Lintott Bsc IT (RAU)
|
|
|
|