|
You can use the System.Diagnostics.Process class for this (redirecting the standard output). A detailed example is available here:
MSDN: Process.StandardOutput[^].
|
|
|
|
|
Hello everybody .
i just need to know the following:
==================================
1 - i have ADSL connection , i need to make my ip address globally accessible , On Dial up connection my ip address was globally accessible by other users on the internet but not on ADSL , i just need to know how and if using port forwarding ( i need a total explanations or links for explaining that step by step ) knowing i tried the article here on codeproject on port forwarding but it didn't work with me , i don't know why.
Human knowledge belongs to the world.
|
|
|
|
|
Usually with an aDSL connection you are given a private address and that is mapped to a global address by your ISP.
To verify, go to start run and type cmd and then ipconfig
There you will see your ip address. (private ranges start with 10. or 172.16. or 192.168. and so on)
Have a look at http://www.ippages.com/ to see your real ip address. This is the one everybody can see.
If that ip works for you, then you should need anything more configured.
If you have a router you can either make manual port forwarding and/or UPnP
Read about those http://en.wikipedia.org/wiki/Universal_Plug_and_Play and http://en.wikipedia.org/wiki/Port_forwarding
Hope i could help
And a good place to learn how to port forward on alomost any device http://portforward.com/
|
|
|
|
|
In Belgium the basic ADSL subscription gives you a different IP address every time you
log on to the ISP; a premium subscription is required if you want your IP to be
constant (so you can set up a publicly available server).
Luc Pattyn
|
|
|
|
|
Dear Friends,
How to connect SFTP(Secure FTP) using C# code?
Regards,
Sireesh
-- modified at 4:17 Sunday 31st December, 2006
|
|
|
|
|
Hi,
I have a listview with check boxes enabled. I want to delete the item when the check box is toggled.
I am happy to do this immediately or on a button control that goes thru the listbox and deletes all the checked items.
I have searched the net high and low and cannot find how to pass the index of the selected items to the delete line as in the following examples:
this.listView1.CheckedItems[a].Remove();
OR
this.listView1.SelectedItems[a].Remove();
How do I determine the index of the item to be removed?
Glen Harvy
|
|
|
|
|
Hi!
I think there's a little misconception on your side: You don't want to remove an item from the list of checked or selected items but from the listview's item list itself.
So you could write something like this:
foreach (ListViewItem it in listView1.CheckedItems)
listView1.Items.Remove(it);
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Thanks for that.
Much appreciated.
Glen Harvy
|
|
|
|
|
In my app, I create event handlers for events supplied by iTunes, like this:
itunes.OnDatabaseChangedEvent += new _IiTunesEvents_OnDatabaseChangedEventEventHandler(itunes_OnDatabaseChangedEvent);
When I no longer want to get these events, how do I do this?
I could simply set a flag and stop reacting to the events, true. But is there a more graceful way? In fact, is there a way to indicate that I no longer want the events sent?
In fact... what causes me to start receiving the events in the first place? Is it the creation of the handler, or did I start getting the events as soon as I created the iTunesApp instance?
At any rate, thanks in advance for your information.
|
|
|
|
|
You registered for receiving the event using += . If you don't want to be notified any more, simply use exactly the same line, but with the -= operator.
|
|
|
|
|
I have the following code snippet:
WebRequest request = WebRequest.Create(URL);
request.Method = "GET";
request.ContentType = "text/xml";
WebResponse response = request.GetResponse();
System.IO.Stream stream = response.GetResponseStream();
System.IO.StreamReader streamReader = new System.IO.StreamReader(stream);
String document = streamReader.ReadToEnd();
this.webBrowser1.DocumentText = document;
I have got the HTML content successful but it lack of the javascript blocks. Then I try to show it into the WebBrowser control, everything is OK except the webpage's images.
How can I solve this problem?
Thanks for your help!
Hung
|
|
|
|
|
I am trying to, in my web browser, have the show source HTML Option, but i would like it to show up in notepad like internet explorer does. How do i do this? Thanks.
|
|
|
|
|
you could try something like this:
void OpenWithNotepad(string f) {
Process proc=new Process();
proc.StartInfo.FileName=@"C:\WINDOWS\system32\notepad.exe";
proc.StartInfo.Arguments=f;
proc.StartInfo.UseShellExecute=true;
proc.Start();
}
Luc Pattyn
|
|
|
|
|
I'd figured I would need a reference, and it says I do ("the type or namespace 'Process' could not be found.( are you missing a using directive or an assembly reference?)") this error occured twice. Thanks!
|
|
|
|
|
Hi,
When scrolling in a listview in details view, the gridlines are overwriting the text.
Has anyone else seen this or is it me!
Glen Harvy
|
|
|
|
|
Hi,
is there a way to point with a string to a specific class?
I want deserialize a XML-Stream into a structure of variables.
I tried with
Score = (score)serializer.Deserialize(reader);
but all members of Score are null.
I suppose that the xml-file is not compatible with seriliation. So I want do the deserialisation by my own code.
This leeds to the question above: If I read an XML-element, how can I assign the XML-attributes to the approprieate element-class?
Ariadne
|
|
|
|
|
You can use the XmlElementAttribute and XmlAttributeAttribute to map specific XML elements and attributes to specific object fields and properties.
See also: Introducing XML Serialization[^]
-Phil
|
|
|
|
|
Class names are PascalCase and variable names are camelCase:
Score score = (Score)serializer.Deserialize(reader);
On two occasions I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question. - Charles Babbage
|
|
|
|
|
Hi,
I've got Creative Infra Remote and I want to get it working. Yes, it does have some program that comes with it, but I want to try to write my own. The remote is this one:
Creative Infra Remote
It's using COM port. I connected it and remote itself is working (I verified it by installing supplied software).
The problem is I cannot get it working with NET2.0. I've looked at several articles here on codeproject and on the web, I created test app, but it just won't work. I create SerialPort class using IO.Ports namespace, I open port and then I try to read data either on a button or using DataReceived event and yet, no matter what I try it won't work. The event never fires. I know port is opening because when I run software supplied with the remote and my application at the same time, whenever I try to open port in my test app it throws exception that COM1 port is already used and access is denied. However, even though the port is opened I cannot receive any data.
Am I supposed to receive any data at all using ReadLine or Read or ReadExisting methods? Or am I supposed to do something else? Can anyone point me in the right direction?
Thanks.
|
|
|
|
|
JazzJackRabbit wrote: The problem is I cannot get it working with NET2.0.
You can't get it working with your app, not .NET. Did you open the correct COM port? Did you use the correct parameters?? Baud rate, data bits, stop bits, flow control?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Yes, the port is correct, COM1. I did not use any parameters since I don't know what they are supposed to be and all of the examples I've looked at use default (empty) constructor.
I actually don't know if I can get it to work at all. I've downloaded WinLIRC, just to see if it will be able to read data from remote, but it won't work either.
-- modified at 18:06 Saturday 30th December, 2006
OK, now I'm getting somewhere. Googled for CIMR100 which is the name of the receiver and used the following settings:
m_SerialPort = new SerialPort("COM1",9600,Parity.None,8,StopBits.One);
m_SerialPort.DtrEnable = true;
m_SerialPort.RtsEnable = true;
And it appears to work, at least DataReceived event is firing.
I get an error though: "Cross-thread operation not valid: Control 'txtInput' accessed from a thread other than the thread it was created on." when I try to show data which was read, but at least that's a start and I can work with it.
|
|
|
|
|
hi,
good that u got it working.
the last error u mentioned is a result of check by the runtime that a thread can access a control only if it created that control. possibly you are accessing txtInput created by 'Main' thread in some other thread. have a look at this.
http://msdn2.microsoft.com/en-us/library/ms171728(VS.80).aspx[^]
regards.
|
|
|
|
|
Yes, I've read this webpage already (that's what VS IDE advised to read when it displayed the error). I don't multithread for now and I don't think I will (doesn't make sense in an app like this, although it may change later). For now all I have is one main form frmMain, I create SerialPort object on the main form, I attach DataReceived event to the SerialPort object and let it be.
Basically something like this:
m_SerialPort = new SerialPort("COM1",2400,Parity.None,8,StopBits.One);
m_SerialPort.DtrEnable = true;
m_SerialPort.RtsEnable = true;
m_SerialPort.Open();
m_SerialPort.DataReceived += new SerialDataReceivedEventHandler(m_SerialPort_DataReceived);
void m_SerialPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
txtInput.Text += " " + m_SerialPort.ReadExisting();
}
Funny, I only see this error when running application from VS IDE. If I run executable from release folder it runs just fine, no error thrown or nothing. This may sound dumb, but this is the first time I see an error like this when I simply access textbox from an event. Am I missing something here, have I been doing something fundamentally wrong for the past three years? And why do I only see this error when running IDE, not executable?
|
|
|
|
|
I expect most IO drivers to use at least one additional thread to handle incoming data:
it needs buffering, decoding, signalling, etc even when there is no client thread actively
asking for anything from the IO. The obvious way to achieve this is for the IO
code to create a local thread;
when something needs signalling (thru a callback function, an event
handler, whatever), I expect that to be handled by the same additional thread.
If you want to verify this theory, you should try to obtain a thread ID (I do not
know by heart how to do this with managed code), do it once in the GUI thread,
and once in the DataReceived handler, and compare them !
Even simpler, you could just print the value of someControl.InvokeRequired from
within the DataReceived handler; if it is true, the above has been proven.
Also the MSDN documentation clearly states "The DataReceived event is raised on a secondary thread when data is received from the SerialPort object".
(see ms-help://MS.VSExpressCC.v80/MS.NETFramework.v20.en/cpref8/
html/E_System_IO_Ports_SerialPort_DataReceived.htm)
So in order to access GUI elements from receive handlers (DataReceived, and similarly
PinChanged and ErrorReceived) you should use Invoke and/or BeginInvoke to delegate the GUI work to the right thread.
BTW, that your program works right under some circumstances does not prove it is
correct; especially threading and synchronization problems can be hidden and
only show under some circumstances. Only correct code works all the time.
-- modified at 22:34 Saturday 30th December, 2006
Luc Pattyn
|
|
|
|
|
OK, thanks a lot for explanation. I'll continue playing with it for the next couple of days/weeks, hopefully I won't lose my interest in it after a few days just like with many of my other projects
|
|
|
|