|
You're using the wrong class. StreamWriter is used for writing character data to streams. To save an image to a file, you need to use a class that will handle a binary stream of data. FileStream[^] is the most appropriate class to use. Your code would look like:
myFileStream.Write((byte[])dsExportDataTypes.Tables[0].Rows[i]["ATTACHMENT"]);
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Hai All,
How can we open only one instance of a form at a time from a MDIparent form in C#.net
Thanks & Regards
|
|
|
|
|
this condition on Form1 would ensure that there's only one copy in the existence
if(obj == null || obj.IsDisposed)
{
obj = new Form2();
obj.Show();
}
Sathy
|
|
|
|
|
You can do that by having a "manager" class that manage the child form.
1. Caller call a method in the manager, given the type of the form that you want to open.
2. Manager check MdiChildren of that type, if it finds it, return the form object back to caller.
3. If manager not able to find it, then create a new instance via reflection, then return back to caller.
4. Caller receive the form, do necessary action on the form (pass object, show, etc)
You can mix it up a bit by having some form can only be opened as 1 instance, while other form can be opened multiple time, by adding customattribute to the form class or adding an "AllowMultiple" via subclassing Form.
This is by no means the only way.
|
|
|
|
|
Any idea on mouseover outside the form?
eg:the form is not on focus and when i mouseover a text from another program an action will trigger.
|
|
|
|
|
i think you can not do that because you will be out of the scope of the event,
but try to google for background processes something like that to capture the mouse.
|
|
|
|
|
thanks but, may i know how is actually API SPY 2.7 work? when we use mouse to mouseover others windows form object, it will show the object handle, text, class and so on. it zit related to as what you hav mentioned background processes?
|
|
|
|
|
Handle NC_MOUSEMOVE .
/ravi
|
|
|
|
|
I want to drag one picture from my HTML browser(e.g. IE7) and drop it to my windowsApplication.
In final address of picture(e.g. "Http://www.tinypic.aaaaaaa.jpg") appear in windowsApplication.
I would be very thankful if anyone provide me Sample.
|
|
|
|
|
Boroumandan wrote: I would be very thankful if anyone provide me Sample.
This isn't how the site works. People don't do your work for free.
What research have you undertaken to solve your problem? What code have you already tried to write?
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
hi guys ....im just intresting in serial port programming one simple one i want try now just connecting one gang way switch to PC via serial port.
method:
when switch was pressed, application should display "switch has been pressed"
any ideas ?
so much of happy ending...
|
|
|
|
|
if u r using VS 2005 you will find SerialPort Control in the toolbox.
just added it and specify it is com number and bouadrate then open it and read
|
|
|
|
|
I found a good example about serial port in this link, you can use it:
http://www.codeproect.com/KB/cs/serialcommunication.aspx
Sourie
|
|
|
|
|
Hi,
How do i display the select names dialog box in outlook 2003 in my program. The same can be achieved in Outlook 2007 by using the SelectNamesDialog.
Please advice.
|
|
|
|
|
Hi all,
I just want to add several controls at runtime like dropdown list, text box abd button. And, when we click the button again one row will be added with the set of controls likewise.can anyone please help me?
Thanks in Advance.
Thanks & Regards,
Radha
|
|
|
|
|
Duplicate Post
Please Check the answer in Asp.Net Forum !!!
|
|
|
|
|
Sorry.. I m new to this one.So, i m not sure whether to post this in C# or Asp.net.. So i did post in both discussions.
Thanks & Regards,
Radha
|
|
|
|
|
I think now you know which is the right fourm to post which Topic
|
|
|
|
|
Hi everybody, recently i have big problem of software development
my Question is that.
- How to call Dot net Web-Services in php/Java ?
Advance Thank
|
|
|
|
|
Please don't cross post. It's rude
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
static public void ToFile<t>(T[] vec, string name) where T : IEnumerable<t>
{
using (StreamWriter sw = new StreamWriter(name))
{
foreach (T v in vec)
sw.WriteLine("{0}", v);
}
}
Now to call that function with:
double[] vec = { ...some numbers ... };
ToFile.(vec, "filename.txt"); <---- error double[] sould be IEnumerable
chesnokov
|
|
|
|
|
You can't do that. You've constrained T to be enumerable, but T in your example is double and not an array of doubles.
|
|
|
|
|
it is ... T[] vec ... if this is what you meant.
How to do it any way?
chesnokov
|
|
|
|
|
Well, in your example, the compiler will map to double, and that will break the T:IEnumerable constraint. I guess you simply want the first parameter to be enumerable, in which case,
static public void ToFile(T vec,string name) where T : IEnumerable
{}
will work. Or, if you want to ensure that the caller passes an array of T, you could do away with the constraint, arrays are always enumerable.
|
|
|
|
|
I need to use the code like:
int[] vec1 = ...
double[] vec2 = ...
etc...
ToFile(vec1, "file1.txt");
ToFile(vec2, "file2.txt");
If you remove 'where T : IEnumerable' the foreach statement will not compile, if you keep 'where ...' the ToFile(vec, "filename") will not compile
Would you provide here your modification of ToFile() that compiles along with its invocation with vec1, vec2, etc...
chesnokov
|
|
|
|