|
i need the information abt how to transfer the values from a particular file, which is in one form, to their respective text boxes which is other form
|
|
|
|
|
string content = File.ReadAllText(file) will read the contents of a file into a string .
Do whatever you want with this string then
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
|
Hi,
I have written a program in which I use a dll that is not .NET.
If I use the part of the program that is only .Net, it works fine. Also if I use only the part that uses the dll. BUt if I use in order the .Net part and then the dll, it gives me an AccessViolationException.
This is a MultiThreading Environment.
I modified the prog so the two part doesn't have anything in common, but it didn't help.
So those are the questions:
- Does the FrameWork move objects? So if I register an event in my dll with a reference, it can be not valid after a while?
- How can I get the memory position of an object?
This is part of the class that imports the dll:
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
private delegate void SM_MONITOR_PROC(string scanner_id, int evnt, int param);
private delegate void SM_IMAGE_PROC(string scanner_id, int width, int height, System.IntPtr ptrImg, int resolution, int param);
private delegate void SM_STATE_PROC(string scanner_id, int state, int param);
[DllImport("scanman.dll")]
private static extern int SMInitialize();
[DllImport("scanman.dll")]
private static extern int SMFinalize();
[DllImport("scanman.dll")]
private static extern int SMGetScannerCount();
[DllImport("scanman.dll")]
private static extern int SMGetScannerId(int index,System.Text.StringBuilder id, int len);
[DllImport("scanman.dll")]
private static extern int SMStartCapturing(string scanner_id, SM_IMAGE_PROC image_proc, SM_STATE_PROC state_proc, int param);
[DllImport("ssl.dll")]
private static extern int UseDirectCallbacks(int use);
[DllImport("scanman.dll")]
private static extern int SMStopCapturing(string id);
Then I associate a function with the event SM_IMAGE_PROC like this:
SMStartCapturing(ID, new SM_IMAGE_PROC(image2), new SM_STATE_PROC(state), 0);
- The last thing is: I'm using this structure:
Main Class -> ClassManager
-> ChildClass
When I create the childClass, I pass to it the ClassManager instance, so then it can use some methods that I need from there.
What I'm thinking of is that somehow the position of ClassManager changes and ChildClass tries to get the old reference.
Any Idea?
or Any Idea of where else Can I look for an answer?
|
|
|
|
|
ilmarga wrote: Does the FrameWork move objects?
Yes, garbage collection also compacts the heap, so the actual address of active objects can move as the result of a GC.
If you need to insure an address does not change, you must "pin" it. see this for more info[^].
|
|
|
|
|
Hi;
is there a dll or any thing usefull for getting the bytes sent and recieved over the internet just like the windows status dialog when you connect to the net.
I connect through DSL.
I want to get the amount bytes recieved and sent.
thanks,
Riazi
|
|
|
|
|
As I know there is no API for this purpose. It is used very common, may be someone has his own code and want to share;)
|
|
|
|
|
Hello,
I'm new to C# .Net 2, though not to programming, and I'm having some trouble with an object I've created.
ProductStatus is an object that i have used implemented as a List<T> . It is filled from a database, each new record is a new ProductStatus .
My question is, how do I return a sepecific entry from the list, using <T>.Contains for instance, but without having to pass an entire ProductStatus in? For instance just passing in the Name, or it's ID number.
If anyone could recommend some reading about Generics and Collections in C#, that would be just fudgin awesom-o, too.
thanks
|
|
|
|
|
nevermind I used Dictionary<T> in the end.
|
|
|
|
|
For future reference, you can use the generic List's Find method. For example, if you had a list of strings, and you wanted to find the first string starting with "hello", it'd look like this:
string startsWithHello = myStrings.Find(MyCriteriaFunction);
...
bool MyCriteriaFunction(string input)
{
return input.StartsWith("hello");
}
Alternately, you can use anonymous methods to do this in a more concise manner:
string startsWithHello = myStrings.Find(delegate(string input)
{
return input.StartsWith("hello");
});
The next version of C# includes syntax for writing lambda expressions, which simplifies this further:
string startsWithHello = myStrings.Find(s => s.StartsWith("hello"));
Additionally, the next version of the .NET framework will include System.Query.dll, allowing for language integrated query syntax. C# 3 takes advantage of this, and will allow you to write something like this:
string startsWithHello = from s in myStrings where s.StartsWith("hello");
|
|
|
|
|
dear all
i tried to use the WebBrowser and i used the code
webBrowser.Navigate("C:\\m.mht")
but the file didnt previewed in the form
Mohamed Magdy
|
|
|
|
|
I have been working on a custom control, and it's almost finished, but i don't know how to turn the .cs class file into a .dll. Can you help me?
rzvme
|
|
|
|
|
If you have an VS project, open the project settings, select the first tab called Application and choose Class Library as output type.
If you want to compile with csc.exe directly take a look at its command line options in MSDN. There is one (/o if I recall correctly) that allows you to select the output type.
"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
|
|
|
|
|
if you have extra code in the same project remove that code or create a new class library project and copy your files in that projects folder include them build it and you have it
if you want the release version of your dll then build it in release mode and you have it
It is Good to be Important but!
it is more Important to be Good
|
|
|
|
|
Hi,
Within my background worker's DO_WORK method, I have following code,
......................................................<br />
webBrowser1.navigate("http://www.google.com");<br />
while(weBrowser1.ReadyState != RedyState.Complete)<br />
Application.DoEvents()<br />
....................................................
Now, when the background worker is being executed, webbrowser1 is being loaded with the mentioned website nicely without any problem. But the problem is, when it checks the ReadyState, it stays uninitialized forever and never reaches ReadyState.Complete and thus, the thread never exists. I checked the code with so many website url so there is no chance that I am having problem to load google.com.
I dont have this problem when the same code is being executed in the standard main thread. Only problem when the code is being run in a background worker thread.
Please help... and your co-operation is appreciated.
Emran
-- modified at 3:23 Sunday 5th November, 2006
|
|
|
|
|
Why don't you register to the WebBrowser.DocumentCompleted event instead of actively waiting for the ReadyState property to become Complete .?
It's always complicated to access visual controls from threads other the one they were created on. Take a look at this article to get a general idea how to bypass. What's up with BeginInvoke?[^]
Furthermore the call of Application.DoEvents from a worker thread isn't necessary as the use of the worker thread already keeps your application responsive (in a much nicer way than DoEvents).
"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
|
|
|
|
|
bashiwala wrote: while(weBrowser1.ReadyState != RedyState.Complete)
Should that not be ReadyState.Complete?
|
|
|
|
|
May be the problem is using " Application.DoEvents()" in the delegate function. Using this method outside of the delegate function or DoWork method may be useful
|
|
|
|
|
Hello,
Let's say I have a variable named: someVar which contains the following:
href wow nice this <a href="cp.com">cow duck john</a> text etc
And I want to replace: "href" with "link". I can't do:
someVar.Replace("href", "link");
Because that will change: <a href="cp.com"> !
So, how can I replace all the occurances of "href" when it's not part of an HTML tag?
Please help.
|
|
|
|
|
hi
for something simple like that just try this:
someVar = someVar.Replace("<a href","|||||||").Replace("href","link").Replace("|||||||","<a href");
the ||||||| can be replaced by anything as long as it's unique
hope that helps.
|
|
|
|
|
Try this REGEX, I hope it will be useful. You can use any variable instead of link word in the following snippet.
string ResultString = null;<br />
try {<br />
ResultString = Regex.Replace(someVar, "(>.*?)(href)(.*?<)", "$1link$3",<br />
RegexOptions.Singleline | RegexOptions.IgnoreCase | RegexOptions.Multiline);<br />
} catch (ArgumentException ex) {<br />
}
|
|
|
|
|
I was wondering if there is a way to detect if a process is executed, preferably with an event.
|
|
|
|
|
Hi,
You can easily create event handler for a process instance. IF you use Process Instance from Design mode, then you will see that, there is an event named EXITED available in the event list for that instance of component. If you are creating your process within your code, then you can use the following snippet.
........................................................................................<br />
<br />
System.Diagnostics.Process myProcess = new System.Diagnostics.Process();<br />
myProcess.Exited += new EventHandler(myProcess_Exited);<br />
<br />
void myProcess_Exited(object sender, EventArgs e)<br />
{<br />
throw new Exception("The method or operation is not implemented.");<br />
}<br />
<br />
....................................................................................
|
|
|
|
|
I'm sorry but I should a written my question better, I need to run some code when a user runs a specific application on the computer, such as a game.
But thanks anyway.
|
|
|
|
|
i need to access a file in one form and print the contents of the file to the textbox which is in other form....
|
|
|
|