|
Not without performing the algorithm that would run on it, which you could to to an in-memory stream (MemoryStream ) to determine the size.
BUT...
You can't save a binary stream to XML. You can use a number of different encodings but by far the most popular is base64. You don't need to know how big it'll be anyway, because you just perform the encoding and set the value on an XML element (or attribute, but data that large isn't really fit for attributes).
The XmlTextWriter class makes it easy to accomplish this using the XmlTextWriter.WriteBase64 method. The XmlTextReader.ReadBase64 does the opposite, of course.
Remember, though, that you don't need to allocate space in an XML file (unless you're doing some weird pre-empted packing routine). It's just a text file and like all text files will grow or shrink (within disk capacity) to accomodate the contents.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Dear Heath,
First of all thanks for your replay but i think i did not rech my information to you, as i have seen the best way to pass an dynamic image to the crystal report is using the dataset which is in the last form is XML so you have to write it into the the dataset classes and for that you have to use the memory stream and when you like to write to the memory stream you have to allocate an enugh memory space for that bitmap then you write it to the stream so in my test project i have used the max size which can be callulated by size = width * height * 3 + 100 this size is for the normal bitmap not JPG and when i wrote to the stream i found that about 1/3 from the stream is still empty so if you know a way to mesure the size of that bitmap before allocating the memory stream could you help me in this mater
Regards
|
|
|
|
|
Actually, I already gave you a clue in my first paragraph: MemoryStream . Save the Bitmap as a JPEG to a MemoryStream and determine the length by checking the Length property. Also, you don't need to preallocate space in a MemoryStream if you use the right constructor.
You didn't mention before that you weren't saving the XML file to disk. While you can use CDATA sections to write binary data, this is not recommended - especially when you persist XML to disk or for transport. This is where binary encodings like base64 are necessary. If Cyrstal isn't extensible enough to base64 decode an image, then you'll have to keep doing what you're doing.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Dear Heath ,
which constructor do you mean i have seen all the memory stream constructors should take the capsity of the stream so could you specify the constructor
Thanks,
Mhmoud Rawas
------------
Software Eng.
|
|
|
|
|
Opps ..... Sory i have found it if i use the defualt constructor it takes a dynamic stream
Mhmoud Rawas
------------
Software Eng.
|
|
|
|
|
Sorry the last replay is from me but i was not loged in
Mhmoud Rawas
------------
Software Eng.
|
|
|
|
|
How could I find the size of a picture (http://www.willapa.wednet.edu/images/amigo.jpg)
When every I try to use .Legnth , it tells my Stream dosn't support seeking... or somthing like that.
Any ideas?
Oh, yeah...
and also, I was wondering if it was possible to do a .GetFiles over the internet....
/\ |_ E X E GG
|
|
|
|
|
When using he HTTPWebRequest a header will be returned with some info including length and modified date.
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
Right, specifically HttpWebResponse.ContentLength and HttpWebResponse.LastModified .
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
This answers my last question too. Thanks.
/\ |_ E X E GG
|
|
|
|
|
How would I identify what type of webserver a site is running? (IIS, Apache, Xitami)
Right now, i'm messing around in the System.Net Namespace but not really finding anything.
Can anyone help me out?
/\ |_ E X E GG
|
|
|
|
|
ok, i just went though every class I could think of on MSDN. I couldn't find anything that stuck out.
Any ideas?
/\ |_ E X E GG
|
|
|
|
|
Just make a HttpWebRequest and get the HttpWebResponse . The HttpWebResponse.Server property returns a string that identifies the server. This corresponds to the HTTP Server: header.
Here's an example:
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.codeproject.com");
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Console.WriteLine(response.Server);
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
hmmm, what do you know... this Heath Stewart character knew the answer to this question.
I'm just curioius, did you sorta know this already. Or did you search for it?
/\ |_ E X E GG
|
|
|
|
|
This - and most solutions I post - I know already. I'm both blessed and cursed with a photographic memory. Besides, HTTP and HTML (if you call that programming) was one of the first programming things I did besides the dinky little things I did on my C64, so the HTTP Server: header was nothing new.
It's not that I always remember the exact method or property, though. In some cases, I know that a certain class has a certain method or property that takes certain parameters and returns a certain type. As I've said many times in the past, it isn't so much memorizing every signature in the .NET Framework (or anything else for that matter), as it is remember that something exists and roughly where to find it. The important part of research is at least becoming familiar with what's available and having an idea of where to look. So, using your question as an example (if I couldn't remember what the property or method was called), I knew it would be on the HttpWebResponse (since the whole pluggable protocol API is aptly and consistently named - the HttpWeb part - and that the client couldn't know what the server was till it got a response back - thus using Response instead of Request) so I would just jump to that class and look.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
That's cool, a photographic memory... I wish I had one!
Thanks for your help. Both times.
/\ |_ E X E GG
|
|
|
|
|
Hello,
What would be the best way to go about making a computer restart after my setup program has finished running?
I can't seem to find anything built-in to the setup program. Will I need to specify a custom action to do this?
Thanks,
Blake
|
|
|
|
|
If you're using Windows Installer, it decides if a reboot is necessary. If - for some odd reason - you need to reboot regardless of what Windows Installer thinks, create a REBOOT property in the Properties table and set it to Force. If you're using VS.NET's installer project, you'll have to download the Windows Installer SDK on the Platform SDK web site, install Orca (copied to your machine as Orca.msi in the PSDK's bin directory), open your compiled MSI, and add the property to the Properties table manually.
If you need to conditionally set it, you can use a CustomAction that sets the REBOOT property to Force. Note the case of the REBOOT property, though - it must be all uppercase.
You could also write a custom action DLL, but it isn't necessary since - as you can see - you can have Windows Installer do it.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thanks for the info.
If I am using the bootstrapper sample form Microsoft's website to do a silent installation of .Net framework, will Windows Installer take the .net framework installation into account when determining if the reboot is necessary? And, I am using MDAC and Jet merge modules in the setup program also. Will it take these into account?
Thanks for the reply!
Blake
|
|
|
|
|
The bootstrapper runs before the Windows Installer package, so Windows Installer won't know. I'm not aware of how the bootstrapper could tell the installer to reboot, since the bootstrapper typically only knows about the Database object (where the properties are read-only). Perhaps the bootstrapper can get the Instance after invoking MSI on the package, but you'd have to read the Windows Installer SDK. I've never had to attempt modifying the installer from the boostrapper to know.
In most cases, though, you want the bootstrapper to reboot before restarting the Windows Installer package. If the .NET Framework installation isn't finalized when your MSI package begins, you may run into problems. While rare, I have had problems where - after installing SP2 - the GAC wasn't setup completely and trying to install assemblies into a GAC that didn't exists screwed some things up. It wasn't disasterous, but your average stupid user using your product might not like it.
As far as Jet and MDAC go (they are merge modules), if Windows Installer determines that files they needed to replace are in use or that the machine needs to reboot (which is stupid in most cases for NT-based Windows OSes because the user need only logout and back on), it will do so either when necessary or at the end, depending on what you set the REBOOT property to. Valid values are Force, Surpress, and ReallySurpress. See the Windows Installer SDK for more information.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Just one comment not on the technical side. If you don't wish to royally piss off most of your users, don't force a reboot at all, unless it is extremely neccesary. Several programs i've used lately have popped up a box at the end simply saying "Click OK to reboot". This is rarely neccesary, and certainly wasn't in some instances.
This is amazingly bad usability design, and is hugely presumptious. Try to avoid this! Just a comment
|
|
|
|
|
This is a moot point with Windows Installer. Setting REBOOT to Force still prompts the user with a Yes/No dialog. Your comment is most definitely valid in a custom installer, but that's not the case here.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Please give it some thought about forcing a clients machine to reboot. Just think how irritating it is when an application reboots your machine. Personaly believe the best option is to place messages in the installer to say a reboot is necessary, and leave it up to the end-user.
My one cent.
|
|
|
|
|
Has anyone used C# to do a mailmerge for word 2002?
I have a CSV file that is coma delimited that is created by a web page. Need to take that CSV file and have it do a mailmerge to a Word doc.
|
|
|
|
|
Anonymous wrote:
Has anyone used C# to do a mailmerge for word 2002?
Google is your friend. Go to Google and do a search on the keywords in your question (hint)[^].
Roger Stewart
"That is disgusting... Yet oddly fascinating!"
|
|
|
|