|
In the method declaration for InsertDoc , change byte to byte[] so that you are passing in the byte array.
|
|
|
|
|
Hi Pete, thanks for pointing that out but that is what I already have but forgot to type it i when I created this post. The question now is how do I send the memorystream object to the database.
modified 9-Aug-12 4:33am.
|
|
|
|
|
Fair enough, but in future, please try to give us the real code, rather than having us waste your time correcting a problem that doesn't exist.
If all you are trying to do is pass the MemoryStream instead of the byte[] , then just change the parameter, and work with that. But, as you are reading from disk into a byte array, this is a pretty useless conversion step. If, however, you are trying to avoid the creation of the file, and you already have a populated MemoryStream , then you need to create a byte array and populate it from the MemoryStream like this:
byte[] data = new byte[ms.Length];
ms.Read(data, 0, ms.Length);
|
|
|
|
|
Thanks, it seems to be working but I had to modify your code to
byte[] data = new byte[ms.Length];
ms.Read(data, 0, data.Length)
|
|
|
|
|
Good catch. That's what happens when I type directly into the Code Project editor; silly mistakes slip through.
I'm glad it's working now.
|
|
|
|
|
It is a common misunderstanding that the Stream.Read method will read the number of bytes you specify in the count argument. But the count parameter specify the maximum number of bytes the stream is allowed to read. An implementation of a stream is free to return fewer bytes, even if it has not reached the end of the stream. It must return at least one byte unless the end of stream has been reached.
The MemoryStream implementation happens to read all at once - and it is probably unlikely to change any time soon but I would not recommend to get used to this behavior - because then you start using it with other stream types you will get errors.
The easy solution here is to use MemoryStream.ToArray(). In other cases where you need to read a fixed number of bytes from a stream you will either have to make a loop calling Read again if it did not return all bytes or you can for example create a BinaryReader for the stream.
|
|
|
|
|
A very good point, especially as a lot of people don't know that Read returns the count of bytes that it has read.
|
|
|
|
|
Greetings i have been looking for something that can help me put images on google image search, just after taking a picture through webcam, like google goggle, i have tried SBI sharp but it gives var result and its hard to get the image, can anyone guide me what is this called or how can i get this thing working
Thanks !
|
|
|
|
|
If you're talking about similar image search, go to images.google.com and click the camera icon in the searchbox.
|
|
|
|
|
i would like to take picture from camera and upload it to google image search and get result of similar images !
|
|
|
|
|
That's exactly what it does.
You can also try TinEye[^]
|
|
|
|
|
you dont get my point i want to take a picture from my webcam and search it online instantly ! is there any open source prog. for this or what things can help me i need some guide .
Thanks
|
|
|
|
|
Hello
I created more than 20 games on windows phone7 .I want to convert that all games for windows 8 ultrabook but touches are not working properly in ultrabook that means gesture..anyone know how to handle or enable gesture in windows 8 ultrabook
my code is for touches:
In constuctor()
{
EnabledGestures = GestureType.Tap;
}
public override void HandleInput(InputState input)
{
foreach (GestureSample gesture in input.Gestures)
{
if (gesture.GestureType == GestureType.Tap)
{
}
}
}
whenever i am touching windows 8 ultrabook.Its always showing gesture count is 0.
and its not coming inside.
foreach (GestureSample gesture in input.Gestures)
{
}
so how we enable gesture in windows 8 ultrabook.
whenever i am touching windows 8 ultrabook.gesture count comes 0.
its not coming inside.
foreach (GestureSample gesture in input.Gestures)
{
}
so how we enable gesture in windows 8 ultrabook.
please reply me ASAP.
waiting for ur reply
Thank U
Best Regards,
Ashish Gupta
|
|
|
|
|
See this MSDN page[^].
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Perhaps keep your eye on what this company, LeapMotion, is developing: high-precision gestural control without touching the screen:[^].
best, Bill
"Everything we call real is made of things that cannot be regarded as real." Niels Bohr
|
|
|
|
|
Hi,
I need to improve oops advancd concepts and learn advanced in c# dot net.
any one can help to me .
|
|
|
|
|
A good place to start with taking your OO ability to the next level is to understand something called SOLID. Now, a guy called Bob Martin popularised these principles, and you can find details here[^].
In a nutshell, it's how to approach writing complex systems using easy to understand principles. Now, although these principles are easy to understand, it doesn't stand to reason that they are easy to apply. Applying SOLID is hard - primarily because there's always a temptation to cut corners.
Please note that these aren't the only principles you can use - Bob goes on to list other principles that can be applied in the article, but these are a good place to start.
Can I suggest that you change your user name? If you want to be spammed, your user name here is a good way to go about it.
|
|
|
|
|
After you've learned the basics of OOP, read Design Patterns (Gamma et al) for the advanced concepts.
Design patterns are how you use OOP to solve problems.
"Microsoft -- Adding unnecessary complexity to your work since 1987!"
|
|
|
|
|
|
Hi all,
I want list out all the open ports for a particular IP Address in c# windows application.
How can i do it ?
Thanks in advance.
|
|
|
|
|
Have a look at this tip Find an open port on a machine using C#[^].
HTH.
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
The problem with that approach is that it only works for the local machine. I believe the OP is looking to scan ports on remote machines.
|
|
|
|
|
Ahh! Reading the question right is generally a good start
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
You asked this question already, less than a day ago.
|
|
|
|
|
Univote countered
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|