|
Hi all,
i wanna know how call a certen text file that i saved it in certen location & compare it with label .
If the data in text file is equal the data in label show a button ,if not application will exit.
|
|
|
|
|
Dim Reader As New StreamReader("a.txt")
Dim strContent As String = Reader.ReadToEnd
'MessageBox.Show(strContent)
this is in vb.net, the same in c#
Tamimi - Code
|
|
|
|
|
thanx alot
for the code
sorry but how to convert it to c# & if there any ref.
thanx
|
|
|
|
|
StreamReader Reader = New StreamReader("a.txt")
String strContent = Reader.ReadToEnd
Tamimi - Code
|
|
|
|
|
|
This code you have provided does not work in Visual C#!!!!!
Tamimi - Code wrote: Dim Reader As New StreamReader("a.txt")
Dim strContent As String = Reader.ReadToEnd
'MessageBox.Show(strContent)
this is in vb.net, the same in c#
|
|
|
|
|
System.IO.File.ReadAllText will read the file in a single line of code, and will guarentee to close the file. I don't believe the code you were given will close the file.
Use the visible property to show the button if the text is equal. You may want to also call the Trim method to remove leading and trailing whitespace, otherwise you may think it should be equal when it is not.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
thank you i should tell him befor
Tamimi - Code
|
|
|
|
|
I'm using a modem (GMS/GPRS) communication the Internet. Can I use C# to programme for my computer (in network LAN) that receive and send data with this modem? I have a static IP address. If can't then choose way for me, please! who can help me?. as detail and clear as possible!
|
|
|
|
|
Hi,
I want to make application which show the screen of other PC with mouse pointer in C#.net.
any one has idea about it or ready made application or can help me.
--- Please
paresh
|
|
|
|
|
Could you specify what you want in your application?
Best,
Jun
|
|
|
|
|
Thanks for Replay........
i have to develop in my software project that show screen of one PC in other pc with mouse pointer on LAN.
for that i have thought two ways.
- first is capture screen like Print screen key on keyboard then compress the bitmap and then send it to other machine and display. in this more than 12 images should be transfer per second to look like real time.
i have developed this for one image . one image transfers successfully. but, when try to send one by one image. no image is display on other PC.
- the other way is convert images in to video file of 5 -5 seconds or more. and transfer it using stream of bytes like in webpages. but i don't know how to convert images in to video file.
p
|
|
|
|
|
Hi all,
I want to build a progressbar that increment its value depending on other process like retrieving data from sql database.
For the first time it will take some time to retrieve table data and showed in dataGridView, so progressBar should express and represent for the time that it will take to retrieve data.
In the next time, retrieving data will be faster and progressBar will move faster as a result.
Thanks in advance.
|
|
|
|
|
Sounds difficult since you dont know how long it will take to get the data from the database. Perhaps you could first ask the database how many 'hits' your sqlquery would produce, and set the progressbars 'maxvalue' to equal 'hits'. Then finally retrieve one value at a time incrementaly and update the progressbar each time.
If it's the data manipulation that takes time, you'd get all the values in one call to the database, set the 'maxvalue' equal to rows retrieved, and then update the progressbar each time you've prosessed one row of data into the DataGridView.
If you want the progressbar to float in a dialogwindow over the parentwindow, you can make a custom form containing only the progressbar. Let the form take the maxvalue for the progressbar in the constructor and expose the increment method through a public method in the form. Then create the form before you start prosessing data, and call the increment method each time you've prosessed a row. You'd just close it through the eventhandlers when the progressbar reaches 100%.
Best wishes!
-Larantz-
|
|
|
|
|
Hi Larantz, could you show me a simple example. I am using SqlDataAdapter to retrieve my data, so how can I know the number of prosessed rows? Or do you mean that I will use sql query ( SELECT COUNT(*) .... ) ?
|
|
|
|
|
If the full query produces data rather quick, I'd just do that and initialize the progressbar with Minium = 0, Maximum = queryresult.Rows.
Then show the progressbar before starting to process the data, and use the ProgressBar.Increment(1) every time you've processed one row.
Should work out perfectly
-Larantz-
|
|
|
|
|
But how can I do it (get the number of processed rows) by using SqlDataAdapter ?
|
|
|
|
|
Microsoft used to do this with an algorithm that tended to infinity. In other words, during a search, the algorithm would almost - but not quite - reach 100% during the retrieve phase. Once the data was fully selected, the code would update the progress to 100%. Sometimes this meant that the progress would stay at 99% for a long time, other times it would reach 50% and then race through to 100%.
Note that if you want to do this, your other process must run on a different thread to the UI so that you can update the progress bar. There are lots of articles here on CP that tell you how to do this.
Arthur Dent - "That would explain it. All my life I've had this strange feeling that there's something big and sinister going on in the world."
Slartibartfast - "No. That's perfectly normal paranoia. Everybody in the universe gets that."
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Could you help me to find those articles?
|
|
|
|
|
Try this one.
http://www.codeproject.com/csharp/begininvoke.asp[^]
Arthur Dent - "That would explain it. All my life I've had this strange feeling that there's something big and sinister going on in the world."
Slartibartfast - "No. That's perfectly normal paranoia. Everybody in the universe gets that."
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Helow digitalhand,
Have u made it?
|
|
|
|
|
Hi All,
I want to send a Windows message to an application. However, the app is hidden (even to Task Manager).
I tried Process.GetProcesses() but the hidden app could not be found.
How can I attach to such a hidden processes.
Thanks in advance,
JC
|
|
|
|
|
Maybe you can try WMI, if you know its executable name?
Best,
Jun
|
|
|
|
|
Hello Jun,
Thanks for your idea about WMI. I do know the executable name of the hidden process but I am not familiar with WMI. My goal is to send some Windows messages to the hidden process. Could you provide me with some example codes or point me t;)o some clearer directions?
Thanks in advance,
JC
|
|
|
|
|
The following code snippet is from my article[^], which demonstrates how to
1) enumerate the object list and get the object you want (one object for each class) and
2) invoke GetOwner() method of the object under discussion.
When you have got your object, you may invoke its SendMessage() method with an appropriate argument list.
private: static void OnTimedEvent(System::Object* source, System::Timers::ElapsedEventArgs* e)
{
XLogoffThread::mut->WaitOne();
ConnectionOptions *co = new ConnectionOptions();
ManagementScope *ms = new ManagementScope("\\\\localhost", co);
ObjectQuery *oq = new ObjectQuery("select * from Win32_Process");
ManagementObjectSearcher *mos = new ManagementObjectSearcher(ms,oq);
ManagementObjectCollection *moc = mos->Get();
ManagementObjectCollection::ManagementObjectEnumerator* moe = moc->GetEnumerator();
moe->Reset();
while(moe->MoveNext())
{
ManagementObject *mo = dynamic_cast<ManagementObject*>(moe->get_Current());
String *str[] = {"", ""};
str[0] = dynamic_cast<String*>(mo->get_Item("Name"));
if(str[0]->Equals("explorer.exe"))
{
mo->InvokeMethod("GetOwner",(Object*[])str);
if(!str[0]->Equals("SYSTEM") && !str[0]->Equals("System"))
{
CheckGUI(true);
}
break;
}
}
XLogoffThread::mut->ReleaseMutex();
}
Best,
Jun
|
|
|
|