|
Hi,
do you want this ?
Try[^]
Thanks,
Sun Rays
To get something you must have to try once.
My Articles
|
|
|
|
|
I have very weird problem with the windows command prompts standard input.
When i write regular dos command like cd or dir to the input stream everything goes as expected BUT when i want to execute a GUI app (say notepad) the window doesnt show up until i write some empty lines to the stream?
cmd.StandardInput.WriteLine("notepad");
cmd.StandardInput.Flush();
cmd.StandardInput.WriteLine("blaaaaa");
cmd.StandardInput.WriteLine("blaaaaa");
cmd.StandardInput.WriteLine("blaaaaa");
Please help..this is so weird, even my friend google couldnt help me
|
|
|
|
|
add
cmd.StandardInput.Close();
after
Druuler wrote: cmd.StandardInput.WriteLine("notepad");
cmd.StandardInput.Flush();
*12Code
|
|
|
|
|
Hi thanks for ur answer...but im using asynchronous beginreadline and need to keep cmd alive?
|
|
|
|
|
You only need to close StandardInput, not cmd.
*12Code
|
|
|
|
|
hmm...But cmd exits when i close the input stream and even if it didnt exit how would i go about write to the input stream again?
Could you give an code example maybe?
|
|
|
|
|
Hi all,
I am trying to convert a byte array in to a character array and trying to write the character array in a text file...
The character set till 127 is propetly written.. whereas all the characters which is above 127 is modified as '?' i.e ascii number 63.....
How can i write this to the text file...
the code snippet..
Byte[] encryptedData = myrsa.Encrypt(newdata, false);
Char[] asciiarray = encoding.GetChars(encryptedData);
FileStream fs = File.Open(FilePath,filemode,FileAccess.Write);
sw = new StreamWriter(fs, Encoding.ASCII );
sw.WriteLine(new string (asciiarray));
sw.Close();
The above code writes only ascii characters whose values are less than 127 whereas all other characters are automatically changed to '?'
Googled, but no fruits......
Have a Happy Coding.....
|
|
|
|
|
Converting from a byte[] to a char[] is odd, because the two values are not the same at all.
The bytes you (correctly I think) have in your encrypted data are unsigned 8 bit quantities. Chars are 16 bit unicode quantities. Since you are then trying to write these to an ASCII encoded (7 or 8 bit depending on who you talk to) there is some oddness here.
Why not just write the byte[] to a normal filestream? Or encrypt it into the filestream directly? There is a cryptostream, after all...
Here is my generic encrypt routine (uses RSATriple)
public void Encrypt(Stream sIn, Stream sOut)
{
string Routine = "Encrypt: ";
if (key == null)
{
throw new Exception(Routine + EX_CRYPTO_NOKEY);
}
if (sIn.Length > int.MaxValue)
{
throw new Exception(Routine + EX_CRYPTO_TOOBIG);
}
sOut.Write(CreateBlockHeader(sIn), 0, encAlg.BlockSize);
CryptoStream encrypt = new CryptoStream(sOut, encAlg.CreateEncryptor(), CryptoStreamMode.Write);
int inputLength = (int)sIn.Length + encAlg.BlockSize;
byte[] abIn = new byte[inputLength];
sIn.Read(abIn, 0, inputLength);
encrypt.Write(abIn, 0, inputLength);
encrypt.FlushFinalBlock();
key.Reset();
if (sIn.CanSeek)
{
sIn.Seek(0, SeekOrigin.Begin);
}
if (sOut.CanSeek)
{
sOut.Seek(0, SeekOrigin.Begin);
}
}
[EDIT]Edited to correct spelling errors caused by dyslexic keyboard[/EDIT]
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Hi Thank You so much for the valuable input...
But even in a different encoding style(UTF-8, UTF-32 etc) the characters are not written to the file......
Any clues on that>???
Have a Happy Coding.....
|
|
|
|
|
Because the data you start with is not UTF, or ASCII or any other character set based data. It is raw bytes. Unsigned 8 bit values. Why convert these? In your example:
Byte[] encryptedData = myrsa.Encrypt(newdata, false);
Char[] asciiarray = encoding.GetChars(encryptedData);
using (StreamWriter sw = new StreamWriter(filepath, FileMode.Create))
{
sw.Write(encryptedData, 0, encryptedData.Length);
}
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
You can't use GetChars to decode the encrypted data into text, as it's not text that was encoded in the first place.
If you want to represent the data as text, you can for example use base64 encoding:
string text = Convert.ToBase64String(encryptedData);
If you want to save the data to the file without changing it, you should write it as bytes, not as text:
File.WriteAllBytes(FilePath, encryptedData);
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Yes!!! exactly!
I have modified the code in the following way...
Byte[] encryptedData = myrsa.Encrypt(newdata, false);
FileStream fs = File.Open(FilePath,filemode,FileAccess.Write);
sw = new StreamWriter(fs, Encoding.ASCII );
sw.WriteLine(Convert.ToBase64String(encryptedData));
Thank you all for the help!!!
Have a Happy Coding.....
|
|
|
|
|
In the past I had trouble with a PictureBox es MouseUp event, but that fixed itself and never got an issue afterwards.
Now another of its events is causign me headaches.
MouseDown should occur when the cursor is above the control while a mouse button is held down, right?
So, selecting multiple cells in Excel uses the same principle or?
My problem is that I have a lot of PictureBox es directly next to each other and with the MouseDown event I wanted the user to select multiple PictureBox es.
Yet, it gets fired only once for the first time you click and hold a mouse button, it should get fired every time you select another PictureBox , but it only gets fired again after releasing the mouse button and pressing it again.
Of course, that makes selection impossible.
Could anyone tell me what went wrong and how can fix it?
I'm trying to achieve the same effect with the MouseHover event, but that will be a makeshift solution at best.
EDIT:
Scrap that part with the MouseHover event, that doesn't ever fire.
modified on Wednesday, May 6, 2009 5:32 AM
|
|
|
|
|
could you indicate that each picture box has been selected by highlighting in some way when it is clicked (and released). Clicking it again would unselect it. Then when selection of all boxes is complete itterate through picture boxes and if highlighted/selected do whatever it is you want to do?
I guess that involves a selection stage and then an action upon the selected stage rather than happening all in one as I think you wanted
|
|
|
|
|
Megidolaon wrote: MouseDown should occur when the cursor is above the control while a mouse button is held down, right?
Wrong. Mouse down happens when "the mouse pointer is over a control and the mouse button is pressed" - definition from MS.
What this means is that when the mouse button is pressed down, a single event is fired and sent to the control the mouse pointer is over at the time. If it did what you thought, you would get a continuous stream of MouseDown events, which is not what is wanted in most cases. Most people need one MouseDown, one MouseUp.
What you need is MouseDown and then MouseMove (possibly with MouseCapture thrown in for goodmeasure)
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Nah, MouseMove fires the moment you move the mouse, so moving it around over one and the same PictureBox firest it countless times.
I realized MouseHover would do the same and MouseEnter is what I need.
But that event doesn't fire when the mouse button is held down, so it's of no use to me.
I tried catching mouse coordinates before, but they do not correspond to control sizes and I displayed the coordinates when the mouse triggered and event of one a control, but the X coordinate was about 200 higher than the width of that control (which started at the left edge, so the rightcoordinates should have been at most 5 more than the width).
And debugging that is hell, because during if you set set a breakpoint, coordinates will change to wherever the mouse currently is, even if it's not in your application anymore but in VS.
|
|
|
|
|
Yes, thats the whole idea.
You get a Mouse Down, and start tracking the mouse. You can then follow (and select) all the images you wish until you get the MouseUp. The only other way to do the multiple selections is via Control + MouseDown, or Shift and MouseDown - which does not sound like what you want.
I seriously would not consider breakpointing MouseMove!
As a sugestion, set up a form with your images in it, and use Spy++ to examine the mouse messages as you perform the actions you want to do the selections. This should give you a good idea of the message flow you can expect, and you can then see how to handle them.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
It sounds like what you are trying to do may be accomplished better by using the same techniques as for drag-n-drop. Your current approach will only trigger a single mouse-down event so what you will need to do is get the "point" (x,y) position during the mouse down, track the mouse move event and get the "point" (x,y) position at the time of the mouse-up event. Of course this requires you to determine which picture boxes fall within the selection buy comparing their locations.
|
|
|
|
|
Hi,
I want to convert excel file to pdf programatically how can this be done
|
|
|
|
|
Try this[^]
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
i want to use it in web application any free dll available
|
|
|
|
|
Good Day All
I have the Following Code in my DAL
public SqlDataReader Get_Staff_Cycles_internal(String DB)
{
SqlDataReader rd = null;
strcon = GetConnectionString(DB);
con = new SqlConnection(strcon);
cmdselect = new SqlCommand();
cmdselect.CommandType = CommandType.StoredProcedure;
cmdselect.CommandText = "[dbo].[sp_Get_Staff_Cycles_internal]";
cmdselect.CommandTimeout = 0;
cmdselect.Connection = con;
try
{
con.Open();
rd = cmdselect.ExecuteReader(CommandBehavior.CloseConnection);
}
catch (SqlException)
{
throw;
}
finally
{
if (con != null)
{
con.Close();
}
}
return rd;
}
and Am using this code Like this In BLL
public SqlDataReader Get_Staff_Cycles(int ACTIVITY_ID, String DB)
{
DAL.DAL obj = new DAL.DAL();
SqlDataReader rd = null;
try
{
obj.Get_Staff_Cycles(ACTIVITY_ID, DB);
rd = obj.Get_Staff_Cycles_internal(DB);
}
catch (SqlException)
{
throw;
}
finally
{
obj = null;
}
return rd;
}
And am Calling it like this in PL(Presentation Layer)
private void Bind_Grid_For_Staff()
{
SqlDataReader rd = null;
BLL.BLL obj = new BLL.BLL();
try
{
if (Convert.ToString(Session["Selected_ID_Bind"]).Length > 6)
{
String Activityid = Convert.ToString(Session["Selected_ID_Bind"]);
if (Activityid != null || Activityid != "")
{
ArrayList Final_String = (ArrayList)Fixed_String_Multi(Activityid);
for (int i = 0; i < Final_String.Count; i++)
{
rd = obj.Get_Staff_Cycles(Convert.ToInt32(Final_String[i]), Convert.ToString(Session["ActiveDatabase"]));
}
if (rd != null)
{
while (rd.Read())
{
Gridstaff.DataSourceID = null;
Gridstaff.DataSource = rd;
Gridstaff.DataBind();
}
}
}
else
{
lblGridStaff.Text = "Could not Bind StaffGrid";
lblGridStaff.ForeColor = System.Drawing.Color.Red;
}
}
else
{
if (Convert.ToString(Session["Selected_ID_Bind"]) != null)
{
String Activityid = Convert.ToString(Session["Selected_ID_Bind"]);
if (Activityid != null || Activityid != "")
{
ArrayList Final_String = (Fixed_String(Activityid));
for (int d = 0; d < Final_String.Count; d++)
{
rd = obj.Get_Staff_Cycles(Convert.ToInt32(Final_String[d]), Convert.ToString(Session["ActiveDatabase"]));
}
if (rd != null)
{
Gridstaff.DataSource = rd;
Gridstaff.DataBind();
rd.Close();
}
}
else
{
lblGridStaff.Text = "Could not Bind StaffGrid";
lblGridStaff.ForeColor = System.Drawing.Color.Red;
}
}
else
{
Response.Redirect("SubjectStaff.aspx", false);
}
}
}
catch (ApplicationException e)
{
lblStatus.Text = e.Message.ToString();
}
}
i get an Error
Invalid attempt to call MetaData when reader is closed.
and its Poiting to the part that Binds the gridview here
Gridstaff.DataBind();
Thank you
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
Never, ever, ever try to bind an open datareader to a form, while the data reader is open the connection is locked.
Change from using datareader to datatable (uses a datareader under the hood) and it should all fall into place
Vuyiswa Maseko wrote: rd = cmdselect.ExecuteReader(CommandBehavior.CloseConnection);
I use this to return a table
SqlCommand oCmd = new SqlCommand();<br />
SqlDataAdapter oDA = new SqlDataAdapter();<br />
DataSet oDS = new DataSet();<br />
<br />
oCmd = CreateCommand(sProcedureName, arParam);<br />
<br />
oDA.SelectCommand = oCmd;<br />
oDA.Fill(oDS);<br />
<br />
<br />
mvTimeOut = _TimeOut;<br />
return oDS.Tables[0];<br />
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Thanks Mycroft
Am trying to avoid using Datatable because of Performance. That is why i wanted to use a datareader.
Thanks
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
You must have an extroadinary amount of throughput to be able to detect the performance difference between reader and table or is it theoretical peformance difference.
Never underestimate the power of human stupidity
RAH
|
|
|
|