|
Thanks! I already used this function once for Delphi application (anyway, I couldn't remember its name, so I marked your answer as helpful - since it really was ).
I also thought it could have some "cross plataform" C# native code or something, so I could compile with Mono as well, but looks like I'll have to use a few #ifdefs specific for each plataform right?
If you have any more ideas, for the cross plataform issue, I'll really appreciate.
Thanks again,
Dirso
|
|
|
|
|
Hi!
That's quite easy: There's a class SendKeys that simulates a sequence of keystrokes. Since keystrokes are routed to the currently selected control in the active application, this is what you want.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Hey all,
I'm looking for some tips on how to write an update manager for my application. This is what I have in mind and any suggestions on improvements are much appreciated as I'm putting this out of you-know-where.
When my application runs, instead of running the main program, run an "update manager" which just sends an HTTP request to my server to check which files are out of date, if any. The return from this trip to the server will contain the location of the files on my server. Then it will download these updates and run the application.
Firstly, does this open up my application to security threats?
Secondly, is this legal - I know other applications prompt the user before updating anything.
Thirdly, is there a way for the manager to update itself? I was thinking of something along the lines of another exe in the folder which is shelled and somehow knows when the first exe has closed and overwrites it, then relaunches it?
Again, any tips articles, best practices, etc are very much appreciated!
Mike
FREE 28 player online game @ http://www.1483online.com where the community drives enhancements to the game!
|
|
|
|
|
I do the same as you suggest and it works fine.
I simply call a webservice, that returns a version, if installed version below current, it open a prompt to ask the user to download it. Once ok is clicked, I simply download the install exe, and run that, while closing my application.
If the client does not want the application to access the internet, then they should have their own firewalls in place, that is not my concern.
|
|
|
|
|
Hi all.
I have a big XML file, part of that is like this :
<FoxMark>
<NODE ID="14" NAME="Utility" DESC="">
<NODE ID="16" NAME="Crack" DESC="">
<BOOKMARK ID="17" />
<BOOKMARK ID="18" />
<BOOKMARK ID="19" />
<BOOKMARK ID="20" />
<BOOKMARK ID="21" />
<BOOKMARK ID="22" />
</NODE>
</NODE>
</FoxMark>
Now, I want select <NODE ID="16" NAME="Crack" DESC=""> and delete it by LINQ.
I wrote this method but it wasn't work perfectly :
private void Delete(string id)
{
FileName = "file.xml";
try
{
XElement Xelement = XElement.Load(FileName);
var SelectedNode = from node in Xelement.Descendants("BOOKMARK")
where node.Attribute("ID").Value == id
select node;
if (SelectedNode.ToList().Count == 0)
SelectedNode = from node in Xelement.Descendants("NODE")
where node.Attribute("ID").Value == id
select node;
MessageBox.Show(SelectedNode.First().Name.ToString());
XElement Xnode = Xelement.Element(SelectedNode.First().Name);
Xnode.Remove();
Xelement.Save(FileName);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
Can you help me ?
Sorry for my English. I'm a freshman .
|
|
|
|
|
LINQ as it says in the name is a query language. You do not do deletions or insertions or updates with it.
|
|
|
|
|
Thanks leppie. I didn't know it.
But What's your suggestion to deleting specific node in my XML file ?
|
|
|
|
|
To be honest I have never used XLINQ, but your example looks ok (I really just being pedantic about your subject question ).
I just had a look at it, and I cannot see why you code should not work.
If I do see why, I will let you know
|
|
|
|
|
OK
All right.
Sorry for my English. I'm a freshman .
|
|
|
|
|
Who can help me ?
Sorry for my English. I'm a freshman .
|
|
|
|
|
I've highly modified the code found here http://www.codeproject.com/KB/IP/ChatAsynchTCPSockets.aspx.
When creating a packet, I give the following class the info it needs onto which is converts it into a byte[] and visa versa which can then be sent and received by a socket respectively.
public class Data
{
public Command cmdCommand;
public string strMessage;
public string strName;
public Data()
{
cmdCommand = Command.Null;
strMessage = null;
strName = null;
}
public Data(byte[] data)
{
cmdCommand = (Command)BitConverter.ToInt32(data, 0);
int nameLen = BitConverter.ToInt32(data, 4);
int msgLen = BitConverter.ToInt32(data, 8);
if (nameLen > 0)
strName = Encoding.UTF8.GetString(data, 12, nameLen);
else
strName = null;
if (msgLen > 0)
strMessage = Encoding.UTF8.GetString(data, 12 + nameLen, msgLen);
else
strMessage = null;
}
public byte[] ToByte()
{
List<byte> result = new List<byte>();
result.AddRange(BitConverter.GetBytes((int)cmdCommand));
if (strName != null)
result.AddRange(BitConverter.GetBytes(strName.Length));
else
result.AddRange(BitConverter.GetBytes(0));
if (strMessage != null)
result.AddRange(BitConverter.GetBytes(Encoding.UTF8.GetByteCount(strMessage)));
else
result.AddRange(BitConverter.GetBytes(0));
if (strName != null)
result.AddRange(Encoding.UTF8.GetBytes(strName));
if (strMessage != null)
result.AddRange(Encoding.UTF8.GetBytes(strMessage));
return result.ToArray();
}
}</byte></byte>
However on some occasions of high traffic I get the following error:
Index and count must refer to a location within the buffer.
Parameter name: bytes
A first chance exception of type 'System.ArgumentOutOfRangeException' occurred in mscorlib.dll
I feel the constructor which takes a byte array is the cause here. Can anyone suggest a better way of sending this data or point out the problem in the code which I cannot see? Help would be greatly appreciated.
|
|
|
|
|
Please fix the generics in the post. I am pretty sure that is a List of byte.
|
|
|
|
|
At which point do you get this error?
I suspect, the byte[] you pass to the constructor does not contain the correct data.
Add a check in the beginning of the constructor to ensure the byte[] is long enough at least.
|
|
|
|
|
As far as I can tell, I get the error after executing the following commands:
In the OnAccept method..
byte[] bufData = new byte[1024];
clientSocket.BeginReceive(bufData, 0, bufData.Length, SocketFlags.None, new AsyncCallback(OnReceive),
new object[] {clientSocket, bufData});
In the OnReceive method..
Socket clientSocket = null;
Data msgReceived = null;
byte[] bufData = new byte[1024];
bool bypass = false;
ClientInfo cInfo = null;
try
{
bool blInvalidClient = false;
try
{
object[] oData = (object[]) ar.AsyncState;
clientSocket = (Socket) oData[0];
bufData = (byte[]) oData[1];
clientSocket.EndReceive(ar);
}
catch (SocketException)
{
blInvalidClient = true;
}
if (!blInvalidClient)
{
msgReceived = Packet.PacketReceived(bufData);
...
The Packet.PacketReceived method returns new Data(bufData). I've added traces in that constructor and there is something incorrect happening. All clients that communicate use the same Data class to convert the info into a byte[] so it's not as if I'm sending an arb string of bytes to the socket.
But the weird thing is that this only ever happens when I sent lots of packets to the socket at once.
|
|
|
|
|
Problem seems to be here. Not sure I understand why...
if (nameLen > 0)
strName = Encoding.UTF8.GetString(data, 12, nameLen);
else
strName = null;
|
|
|
|
|
It probably does not allow you to read zero strings (assuming it needs a 0 terminator).
|
|
|
|
|
Packets are lost due to this under high load. I'm out of ideas.
|
|
|
|
|
Hmmm. I increased the buffer size from 1024 to 4096 and everything seems to work perfectly now.
|
|
|
|
|
Hi everyone
I am trying to use the Form property TranseparencyKey on a form which is a child for a MidParent from . The result should make the selected color area transparent and so the image of the MidParent form apears .
this feature doe not work , it works only if the form is not owned by a MidParent . any Ideas ?
Thanx .
|
|
|
|
|
Forms do weird things when you make them transparent from my experiences.
|
|
|
|
|
hi guys! I am building an app, and at one point I want to insert data in local DB, everything goes ok, connString is opening, but the data is not going in to the DB, am I missing something in the code?
string query = "INSERT INTO Orders(Order_Name, Order_Data, DateInserted, OrderStatus) VALUES ('"+ Name + "','" + Data + "','" + DateTime.Now + "','" + City + "')";
SqlConnection conn = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\App_Data\OStorage.mdf;Integrated Security=True;User Instance=True;Trusted_Connection=Yes");
conn.Open();
SqlCommand comm = new SqlCommand(query, conn);
comm.ExecuteNonQuery();
I am executing the same query with SSMSE, and it is working without any problem, so I really don't know where I am making a mistake. Thanks ahead for any help
|
|
|
|
|
How many rows affected does ExecuteNonQuery() return? Do you use a SqlTransaction[^] to Commit the changes to the database?
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
It is affecting one row each time the query is executed
|
|
|
|
|
So do you commit the insert using the SqlTransaction.Commit method?
modified 12-Sep-18 21:01pm.
|
|
|
|
|
no, how should I do that? I haven't used that method at all for now, can you pls give me some help how should i use it? Thx
|
|
|
|