|
Try flushing the file stream (and also, you MUST dispose the FileStream as well). Setting it to null is pointless; you only need to do that in Java.
private byte[] getImageBytes()
{
byte[] buffer = new byte[templateStream.Length];
using(FileStream templateStream = File.Open(@"C:\MyImage.gif", FileMode.Open))
{
templateStream.Write(buffer, 0, (int)templateStream.Length);
templateStream.Flush();
}
return buffer;
}
Please note that if you're using the latest version of the .NET framework, you can use the File.ReadAllBytes method, which is more efficient and requires only a single line of code:
private byte[] getImageBytes()
{
return File.ReadAllBytes(@"c:\MyImage.gif");
}
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Bought a House!
Judah Himango
|
|
|
|
|
|
|
Judah Himango wrote: Setting it to null is pointless; you only need to do that in Java.
OT, but I thought the Java GC also worked the same way as .NET, it's mark and sweep and doesn't require references to be set to null?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
In Java, this is a common way of letting the GC know you're done with it. With .NET, it isn't needed. I believe the Java GC would eventually clean up objects even if they weren't set to null, but doing so would supposedly help it along.
|
|
|
|
|
Thanks, just one thing that was horrably wrong, it should be
templateStream.Read(buffer, 0, (int)templateStream.Length);
by using the templateStream.Write(...) it zero's out the image
so it should be
<br />
private byte[] getImageBytes()<br />
{<br />
byte[] buffer = new byte[templateStream.Length];<br />
using(FileStream templateStream = File.Open(@"C:\MyImage.gif", FileMode.Open,FileAccess.Read)) <br />
{<br />
templateStream.Read(buffer, 0, (int)templateStream.Length);<br />
templateStream.Flush();<br />
}<br />
return buffer;<br />
}<br />
<br />
|
|
|
|
|
thomasa wrote: templateStream.Write(buffer, 0, (int)templateStream.Length);
You should be reading from the file, not writing. Anyways your file is blank now, so you will have to create the image, else you will carry on getting zero's.
xacc.ide-0.1.1 released! :) Download and screenshots
|
|
|
|
|
Like leppie said:
FileStream templateStream = File.Open(@"C:\MyImage.gif", FileMode.Open);
buffer = new byte[templateStream.Length];
templateStream.Write(buffer, 0, (int)templateStream.Length);
Shouldn't that be READ??? In either case, the file has already been destroyed when you ran this code for the first time. You'll have to correct the code to Read, then replace the .GIF file with a known good copy.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi.....
Im workin on Icon class where im gettin this exception at the declarartion of the icon obj
private Icon myIcon= new Icon(typeof(Form1)).Assembly.GetManifestResourceStream("winapptry.app.ico" ));
An unhandled exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
with additional info as
Additional information: Could not find file "..\Visual Studio Projects\winapptry\bin\Debug\winapptry.app.ico".
just dunno how to sort tht out
sathy
-- modified at 8:15 Wednesday 28th December, 2005
|
|
|
|
|
First of all you have forgotten a "(" so your code won't even compile.
Check the following:
1. You have a file named "app.ico" in the same project as Form1 (and not in a subfolder).
2. This file is a valid icon.
3. You have set its build action to "Embedded Resource".
4. The root namespace of your project is named "winapptry".
|
|
|
|
|
Thanks a lot Robert
"(" this is bcoz i edited the code here
its the third point is wat i missed out.....
GREAT!!!!!!!
sathy
|
|
|
|
|
Hi ..
i have a few textBoxes that are bounded to a tableview...
but whenever i change my ROWFILTER at the tableview , the Bounded textboxes remain the same...
this is the databind code:
UpdateCoptxtMa.DataBindings.Add("Text",source[0],"Ma");
UpdateCoptxtFirstName.DataBindings.Add ("Text",source[0],"FirstName");
UpdateCoptxtLastNAme.DataBindings.Add ("Text",source[0],"LastName");
UpdateCoptxtAddress.DataBindings.Add ("Text",source[0],"Address");
cboYehida.DataBindings.Add("Text",source[0],"Yehida");
UpdateCoptxtStatus.DataBindings.Add("Text",source[0],"Status");
UpdateCoptxtHomePhone.DataBindings.Add("Text",source[0],"HomePhone");
UpdateCoptxtCellPhone.DataBindings.Add("Text",source[0],"CellPhone");
And the RowFilter code:
source.RowFilter="(LastName + ' ' + FirstName)='"+SelectedCopName +"'";
Thanx! Yosi
|
|
|
|
|
.
.
.
.
.
source.RowFilter="(LastName + ' ' + FirstName)='"+SelectedCopName +"'";
urdataview.RowStateFilter = DataViewRowState.ModifiedCurrent;
i am not so sure but hope helps???
|
|
|
|
|
nope.. when i try using it it throws an exception .
"index 0 is not negative and below total rows cund"
whenever he tries to bind it for example: UpdateCoptxtMa.DataBindings.Add("Text",source[0],"Ma");
i'm lookin for some way , to refresh the textBoxes, ReBInd them i dunno , a way to make them realize that the datasource has changed...!
thanks anyway..
Any other suggestions? please?
|
|
|
|
|
check this link
http://www.codeproject.com/cs/miscctrl/GridFilter.asp
|
|
|
|
|
Hello,
I am C#.net programmer(beginner).I want to disable resize and close button in
my c#.net application.pls anybody help me.i am waiting
alex.
Thanks in advance.
Help Me
|
|
|
|
|
follow this link in the end page u got example in C#.
in load of form write this code
this.MaximizeBox =false;
http://addressof.com/blog/articles/232.aspx
|
|
|
|
|
In the designer, set the form's BorderSyle property to FormBorderStyle.FixedDialog , and set the ControlBox property to false.
I hope this helps,
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
The amount of sleep the average person needs is five more minutes. -- Vikram A Punathambekar, Aug. 11, 2005
|
|
|
|
|
add this.ControlBox = false; in the InitializeComponent() of ur app
sathy
|
|
|
|
|
sir i have to make a gui application in c# that will run a cosole application and will give inputcommands and receive output from that console application. i invoke the cmd.exe in c# using system.diagnostic.process.start() function now i need do pass commands to my process as well as receive output.
please give solution to it and list related namespaces to be used.
sherry; email : shaheryar011@gmail.com
-- modified at 5:32 Tuesday 27th December, 2005
sherry
|
|
|
|
|
You don't need to start CMD.exe. Just start your Console app using System.Diagnostics.Process.Start. To intercept output or give input, you can use some methods of the Process class:
System.Diagnostics.Process proc = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo("myConsoleApp.exe", "any arguments go here");
proc.StartInfo = startInfo;
proc.StandardInput.Write("I'm now inputting text to the console app!");
proc.StandardOutput.ReadLine();
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Bought a House!
Judah Himango
|
|
|
|
|
HI,
I want to disable the MS OFFICE File Menu options and Tollbar Buttons
by using WINDOWS API's..?
We can do this by using MS OFFICE libraries, but i want do using WINDOWS API's.
IS IT POSSIBLE..?
If so PLZ send reply to : pradpb999@gmail.com
pradeep kumar
|
|
|
|
|
Have you tried getting a handle to the menu items in question, then doing a SendMessage to hide it? I'd imagine this could work.
However, I question why anyone would want to do this; sounds either malicious or just a bad solution to a problem. What are you trying to do?
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Bought a House!
Judah Himango
|
|
|
|
|
How do I broadcast IP packets on the network using Windows Sockets?
---
With best regards,
A Manchester United Fan
The Genius of a true fool is that he can mess up a foolproof plan!
|
|
|
|
|
Such a large question to an even larger topic. Check out a book on Network programming.
|
|
|
|