|
Hi everyone,
I wrote an java applet for smart card with eclipse(3.1) ,I wrote oncard and offcard applet and I would like use the offcard applet in visual studio .I mean I need to add the offcard applet in C#,but I don't know how can I do it because I used some type in the offcard applet that they are not known in C#(such as JCTerminal or JCard or OPApplet),If anyone knows the solution please inform me.
yours sincerely ,
Orchid.
|
|
|
|
|
how could i get that in which drive windows is installed?!
|
|
|
|
|
System.Environment.SystemDirectory returns the path to the System directory... you could just get the first character.
|
|
|
|
|
You can retrieve the path of the system directory using the Environment.SystemDirectory property and extract drive information from it:
string windowsDrive = Path.GetPathRoot(Environment.SystemDirectory);
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Dear all,
I want to calculate the execution time of a certain piece of code. I noticed that the min. value I can get is the tick which is equivalent to 100 nanoseconds. I want to know what shall I do if the code takes less 100 nanoseconds, especially on fast computers? I tried to use DateTime class and TimeSpan class but they were of no use. Any help
Regards
islheg
|
|
|
|
|
If you're using .Net 2.0, there is a new class:
System.Diagnostics.Stopwatch
----------------------------
Be excellent to each other
|
|
|
|
|
That still has a resolution of at least 10-15 milliseconds.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
From MSDN:
The Stopwatch measures elapsed time by counting timer ticks in the underlying timer mechanism. If the installed hardware and operating system support a high-resolution performance counter, then the Stopwatch class uses that counter to measure elapsed time. Otherwise, the Stopwatch class uses the system timer to measure elapsed time. Use the Frequency and IsHighResolution fields to determine the precision and resolution of the Stopwatch timing implementation.
The resolution is 0.5 nanoseconds on my 2GHz system, although the overhead of calling Start and Stop seems to be about 10 microseconds.
----------------------------
Be excellent to each other
|
|
|
|
|
Well, it looks like I'm going to have to go back and read that again! :->
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
You'll have to use the QueryPerformanceCounter API. Just search the articles for that term. It's the only timer that has a resolution even close to that.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Why does this throw an error?
byte b=Byte.Parse("4F");
I have this string array of numbers 20 00 08 01 08 4C 82 32 that I want to convert to a byte array. The thing is thought, that I want to treat the numbers literally. It all works fine until i get to 4C in my loop:
for (int i = 0; i < chars.Length; i++)
{
OutputReportBuffer[i] = Byte.Parse(chars[i]);
}
/\ |_ E X E GG
|
|
|
|
|
eggie5 wrote: I have this string array of numbers 20 00 08 01 08 4C 82 32 that I want to convert to a byte array. The thing is thought, that I want to treat the numbers literally. It all works fine until i get to 4C in my loop:
It's not throwing an exception until you hit 4C, but you're not getting what you think you're getting. The Parse() method expects the string to be base 10 (decimal), not hex. Convert your hex value to decimal, then pass it in.
Share and enjoy.
Sean
|
|
|
|
|
Sean Michael Murphy wrote: It's not throwing an exception until you hit 4C, but you're not getting what you think you're getting. The Parse() method expects the string to be base 10 (decimal), not hex. Convert your hex value to decimal, then pass it in.
Even better, let the framework take care of the conversion for you. Check out this Byte.Parse() overload[^], passing NumberStyles.HexNumber in as the second argument.
|
|
|
|
|
Hi Everyone,
I have an application that I wrote in C# that allows users to back up their files to a network storage automatically. It uses the file modification times to figure out which files are newer on the computer than the storage location, and only copies the files it needs to on to the server.
The application starts a thread and the thread does all of the work in the background. What I would like to do is deploy the software to our computers and have it run automatically (and minimize itself) at system logon using a logon script.
I want my application to be able to detect when the CPU usage is at a certain level. If the CPU usage is below, lets say 20%, the application will do it's monitoring and copying. If the application detects the CPU usage rises above a certain threshold, it will suspend its operations and wait around for a while doing nothing.
I don't want the application running all of the time taking up CPU. My users run Photoshop and VS .NET and other applications simultaneously that take up most all of thier CPU.
Does anyone know of a way to detect what the current CPU usage is at? (Not the CPU usage of my application, but total CPU usage of all applications). I saw an article on here that gave you the usage of the current application, but it said it was difficult to do in .NET and they did not know how to do it.
Any help would be appreciated!
|
|
|
|
|
I have done this in ASP.NET, but I am having trouble with it in a C# windows app (that could be because this is my first c# project). At the moment I am just practicing skills against the northwind db.
I have a form with a datagridview bound to a SQL datasource. No problem. I can see and edit the northwind data just fine. I have a textbox that repeats the value of the first column of the selected datagridview row using SelectedCells[0].FormattedValue.ToString(). Works great.
Now, I have a list box that I would like to populate with data from a second table based on the value of SelectedCells[0].FormattedValue.ToString().
How do I do that?
Dave
|
|
|
|
|
Hi,
whats the preferred method of connecting to a database.
a)
create a static SqlConnection object
or
b)
using Sqlconnection = new... {}
having a Using section in every Add, Get, Delete function.
My question is, is having a static object connection open for the duration of the application, a major overhead?
Or is it better (all be it, more code) to have a Using statement, that connects, executes, then disconnects from the database? Thus no permanent connection.
Any thoughts?
Mark
|
|
|
|
|
Microsoft recommends the latter. The SqlClient provider maintains a pool of connection objects (adjustable via the connection string) for each process (the pool is actually keyed by the texet in the connection string, so you should take care to always use exactly the same string content). The ool largely eliminatesw the overhead of creating connection objects (the new... actually justs pulls an exixting idle connection from the pool) so what is left is onloy the overhead of opening the connection which is fairly small. The recommendation is to open the connection as late as possible, and close it as soon as you are done with the operation at hand. Keeping the connection open for the duration runs the risk that your process could terminate unexpectedly and leave a dead connection behind. This will not be reclaimed until the server is restarted. It also ties up a limited resource unnecessarily.
|
|
|
|
|
Microsoft recommends the latter. The SqlClient provider maintains a pool of connection objects (adjustable via the connection string) for each process (the pool is actually keyed by the texet in the connection string, so you should take care to always use exactly the same string content). The ool largely eliminatesw the overhead of creating connection objects (the new... actually justs pulls an exixting idle connection from the pool) so what is left is onloy the overhead of opening the connection which is fairly small. The recommendation is to open the connection as late as possible, and close it as soon as you are done with the operation at hand. Keeping the connection open for the duration runs the risk that your process could terminate unexpectedly and leave a dead connection behind. This will not be reclaimed until the server is restarted. It also ties up a limited resource unnecessarily.
Another reason not to do this is that should your connection become damaged (by a network or server fault) you have no way to recover other than to restart your entire process. Closing the connection when you are done with it (or on an error) and opening a new one whenever needed limits the damage to a single query, which could be retried.
|
|
|
|
|
Hi guys, I have this code:
public void showProcesses()<br />
{<br />
Process[] processes = Process.GetProcesses();<br />
List<Process> killList = new List<Process>();<br />
foreach (Process p in processes)<br />
{<br />
if (!(p.ProcessName == "System" || p.ProcessName == "Idle"))<br />
{<br />
string theProcess = p.MainModule.ModuleName;<br />
processesTest = processesTest + theProcess;<br />
killList.Add(p);<br />
}<br />
}<br />
richTextBox1.Text = processesTest;<br />
}
I keep getting the error: Error 1 'System.Windows.Forms.ColumnHeader' does not contain a definition for 'GetProcesses'
I have referenced System.Diagnostics too, this is really confusing! Any ideas anyone?
|
|
|
|
|
You perhaps named a Column as Process ?
|
|
|
|
|
Hi,
i got a big problem, i have to read in C# a propertyBag that was serialized in VB6 and persisted on a SQLServer Blob (IMAGE) field. So i got it from DataBase and tried Deserialize using this code
byte [] objSerialized = izDAL.loadSession(token)
MemoryStream memoStream = new MemoryStream(objSerialized);
BinaryFormatter binaryFormatter = new BinaryFormatter();
Hashtable sessionBag = (Hashtable)binaryFormatter.Deserialize(memoStream);
IDictionaryEnumerator en = sessionBag.GetEnumerator();
but i got this erros
{"BinaryFormatter Version incompatibility. Expected Version 1.0. Received Version 1426065408.740500660." }
Any idea? I'm using ASP.NET 1.4 framework...
Thx
|
|
|
|
|
The only time I've ever seen that error is in a remoting scenario where the remoting channel is a BinaryFormatter over HTTP. In that case, a problem at the server causes an error while the binary channel is initializing. (Usually it is an exception during channel binding)
The result is a binary error is passed to the client but the client recieves it as what is supposed to be an HTTP text stream. The binaryformatter checks what is returned expecting a version number sent to it (not a binary exception) and returns that failure message. Our workaround to this was to add a switch to the startup process telling the client to put the connection into a soap connection instead of a binary connection and that lets the real error message show.
|
|
|
|
|
I have been having a problem with the mouse button click event. When I double click the left mouse button, nothing happens. The code does not get executed. I need to click the right mouse button in order to get the desired code to execute for the control. That is, the code will not even begin the step through process until the right mouse button is clicked. This is peculiar indeed.
I would like to detect whether the left mouse button is clicked, and when the left mouse button is double clicked, I would like the control to behave as if it were the left mouse button that was double clicked. Also, I presume that there is a need to relate a double click to a single click with regard to the left and right mouse buttons.
I realize that there is an code like so:
private void _ctrl_DoubleClick(object sender, EventArgs e)
{
if (e.MouseButton == MouseButton.Left)
{
}
}
but that does not work. I would request some additional input. How could I get the mouse to only respond to the left mouse button double click without needing the right mouse button in order to perform the required code?
|
|
|
|
|
Hi all:
I am trying to write data back to the Access Database. The following method seems to work well. But I don't understand what the following piece of code exactly work.
<br />
public static void WriteToDatabase(string tableName)<br />
{<br />
System.Data.OleDb.OleDbDataAdapter<br />
databaseAdapter = new OleDbDataAdapter("Select * from "+tableName, conn);<br />
new OleDbCommandBuilder(databaseAdapter);<br />
try<br />
{<br />
databaseAdapter.Update(ds, tableName);<br />
ds.Tables[tableName].AcceptChanges();<br />
MessageBox.Show("Congratulations");<br />
}<br />
catch (Exception ex)<br />
{<br />
MessageBox.Show(ex.Message);<br />
}<br />
}
Could anybody explain it to me please? Or maybe you can give me a better way to write data back to access database please?
Thank you very much
Asura
|
|
|
|
|
hi
i think what are you missing is what the OleDbCommandBuilder dose !!
its define the sql commands from a specific adapter
Tamimi - Code
|
|
|
|