|
hi according to all the needs i am still connected to a server named cerberus ftp server, which is listening on port 21, i think when server client is connected it means thats the authentication is valid.
kindly elaborate use binary to true and how to browse a remote directory.
|
|
|
|
|
I'm working on an InfoPath form that is going to have a repeating table. In this form i'm using C# and WMI to retrieve hardware information for an inventory database. I've managed to figure out how to populate each row with the Network Interface and MAC Address, but i'm having difficulty when trying to get the IP Address, and I suspect i'll have the same problem trying to get the Subnet Mask, so if i can solve one i'll be able to solve the other.
The code i'm using is listed below (i stripped out the other code in there for the hardware not related to the Network Info), but when i use this code, in the IP Address field, it shows "System.String[]" instead of displaying the actual IP Address. Can some one please help me? I got my code samples from the WMI Code Creator and manipulated it to fit in with my existing code. It's pretty ugly right now, but so long as it works i dont care.
using Microsoft.Office.InfoPath;
using System;
using System.Xml;
using System.Xml.XPath;
using System.Management;
namespace Inventory_Rev1
{
public partial class FormCode
{
ManagementObjectSearcher searcherNetwork =
new ManagementObjectSearcher("root\\CIMV2",
"SELECT * FROM Win32_NetworkAdapterConfiguration");
public void InternalStartup()
{
EventManager.FormEvents.Loading += new LoadingEventHandler(FormEvents_Loading);
}
public void FormEvents_Loading(object sender, LoadingEventArgs e)
{
foreach (ManagementObject queryObj in searcherNetwork.Get())
{
int counter = 1;
{
string nicName = queryObj["Description"].ToString();
string nicMac = (queryObj.Properties["MACAddress"].Value != null) ? queryObj.Properties["MACAddress"].Value.ToString() : "";
string nicIp = (queryObj.Properties["IPAddress"].Value != null) ? queryObj.Properties["IPAddress"].Value.ToString() : "";
XPathNavigator xnMyForm = this.CreateNavigator();
XmlNamespaceManager ns = this.NamespaceManager;
xnMyForm.SelectSingleNode("/my:myFields/my:Network/my:AdapterInfo/my:nicName", ns)
.SetValue(nicName);
xnMyForm.SelectSingleNode("/my:myFields/my:Network/my:AdapterInfo/my:nicMac", ns)
.SetValue(nicMac);
xnMyForm.SelectSingleNode("/my:myFields/my:Network/my:AdapterInfo/my:nicIp", ns)
.SetValue(nicIp);
counter++;
AddItem(nicName, nicMac, nicIp);
DeleteFirstEmptyItemNIC();
}
}
}
private void AddItem(string nicName, string nicMac, string nicIp)
{
XmlDocument doc = new XmlDocument();
XmlNode group = doc.CreateElement("AdapterInfo",
NamespaceManager.LookupNamespace("my"));
XmlNode field = doc.CreateElement("nicName",
NamespaceManager.LookupNamespace("my"));
XmlNode node = group.AppendChild(field);
node.InnerText = nicName;
field = doc.CreateElement("nicMac",
NamespaceManager.LookupNamespace("my"));
node = group.AppendChild(field);
node.InnerText = nicMac;
field = doc.CreateElement("nicIp",
NamespaceManager.LookupNamespace("my"));
node = group.AppendChild(field);
node.InnerText = nicIp;
doc.AppendChild(group);
MainDataSource.CreateNavigator().SelectSingleNode(
"/my:myFields/my:Network",
NamespaceManager).AppendChild(doc.DocumentElement.CreateNavigator());
}
private void DeleteFirstEmptyItemNIC()
{
XPathNavigator domNav = MainDataSource.CreateNavigator();
XPathNavigator itemNav = domNav.SelectSingleNode(
"/my:myFields/my:group1/my:group2[1]",
NamespaceManager);
if (itemNav != null)
itemNav.DeleteSelf();
}
}
}
|
|
|
|
|
Look into the System.Net.NetworkInformation namespace, in particular the NetworkInterface.GetAllNetworkInterfaces method. For each one you can call the GetPhysicalAddressMethod. That should make your code cleaner (and faster). This will also allow access to each interface's IP address using the UnicastAddresses property of the GetIpProperties() method
|
|
|
|
|
Hi,
from MSDN: Object.ToString() returns a String that represents the current Object.
The default implementation returns the fully qualified name of the type of the Object.
This method can be overridden in a derived class to return values that are meaningful for that type.
So the output you are getting tells you it isn't a string, it is an array of strings; so have a closer look and discover how you may use that information to your advantage. Chances are string.Join() will come in handy.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
here is the mistake
string nicMac = (queryObj.Properties["MACAddress"].Value != null) ? queryObj.Properties["MACAddress"].Value.ToString() : "";
string nicIp = (queryObj.Properties["IPAddress"].Value != null) ? queryObj.Properties["IPAddress"].Value.ToString() : "";
IPAddress, MACAddress, IPSubnet...all returns string array and you are calling ToString() of string array
here is a code snippet I used
string[] ipaddresses = (string[])netCI["IPAddress"];
string[] subnets = (string[])netCI["IPSubnet"];
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
This has happened a few times to me. I have a form with 3 radio buttons. Here is the code for the form's load event handler: (Ignore variable naming)
this.isLoading = true;
this.RadioButton1.Checked = false;
this.RadioButton2.Checked = false;
this.RadioButton2.Checked = false;
this.isLoading = false;
I have an event handler which handles the checkedchanged of all the three radio buttons. The handler should exit if isLoading is true. However, after the last statement in form's load event, the radio button checkedchanged event is fired and I can not figure out why/how it is fired. Since isLoading is false it goes into the eventhandler of the radio button and one of the radio buttons is checked but how? I have no idea.
How can I figure this out? This has happened to me a few times.
CodingYoshi
Visual Basic is for basic people, C# is for sharp people. Farid Tarin '07
|
|
|
|
|
put a breakpoint inside the event handler and then view the call stack when the breakpoint gets hit. that should help you figure out how it's getting called.
|
|
|
|
|
What might be happening is that if the radioButtons are in a group (all in the same control will do for that), one of them should be checked. They are option selectors, so, one option should be true.
The solution for this depends on what you are using them for, but one way is to add an extra radioButton labelled 'None' and set that to checked.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi,
how about this:
first your Form_Load handler gets executed on the GUI thread; it fires three Button_Changed events, which sit in the event queue since the GUI thread is still busy loading your form. When that is done, and well after you have set isLoading true again, the three Button_Changed handlers get executed by the GUI thread, and they do what you don't want to be done...
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Thank you all for the wonderful suggestions. I will try your suggestions to see what might be causing it.
CodingYoshi
Visual Basic is for basic people, C# is for sharp people. Farid Tarin '07
|
|
|
|
|
Hi , Have a good day ...
I have a little problem in my router simulation program
here is an explaining for it :
suppose I have 5 pionts : pt 1 , pt 2 , pt 3 , pt 4 , pt 5
--------------------------------
pt 1 is connected to pt 2
pt 1 is also connected to pt3
pt 2 is connected to pt 4
pt 4 is connected to pt 5
--------------------------------
so it's very clear that there are two points btween pt 1 , pt 5
pt 1 --- > pt 2 ----> pt 4 ------> pt 5 ...
How I can figure that out in my application ?
I don't need you to write for me a code ( I will glade if you did )
but may be you can help .. in an algorthim , or something like that ...
or provide me with hint ..
and many thank in advance ?
----
P.S
is this is the right place for my Question ?
may be you can tell me where should I ask , such a Question ..
Kind regards
I know nothing , I know nothing ...
|
|
|
|
|
Try googling for "shortest path algorithm".
You might have got more help in the 'Algorithms' Forum.
However, if you do as suggested above and then get stuck in a particular place whilst trying one of the hits out, so long as you are using C#, this would be the right place.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Well, if the points are just a few, I would go with brute force algo.
BTW the right place to post such a question is the Algorithms forum [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
CPallini wrote: the right place to post ...
CPallini wrote: I would go with brute force algo
we don't need a separate forum for your brute force advise, do we?
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Yes, we need the SoapBoxe...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Henry Minute ,thank you very much I googled Shortest path Algorithm ( thats is the word I was looking for )and I find many useful things .. I think I need sometime to read and understand them ... thank you so much
CPallini , thank you very much for the BruteForce solution it's really a brilliant Idea
if I can't solve this problem in the hint you gave me , I will post my Question
in the algorithm forum ,thank you so much
Kind regards ...
I know nothing , I know nothing ...
|
|
|
|
|
Hello all,
regarding tracing everywhere i am coming across this statement:
"in order to enable tracing, the /d:TRACE flag must be passed into the C# compiler or the /d:TRACE=True flag must be passed into the VB compiler."
I added few trace statements (Trace.writeline..) in my project and compiled solution in "Release" mode without any compiler trace flags and my trace statements are working fine, which means trace statements are being logged.
What is the significance of "/d:TRACE" compiler flag?
Thanks.
|
|
|
|
|
I suppose you compile in Visual Studio. Just look at the output window after you compile you project. Visual Studio is adding this flag automatically for you. Search for /define:TRACE
Vitaliy Tsvayer
Tikle
|
|
|
|
|
I see... thanks for the clarification. So, if we build our solution from command line (say using msbuild...) we should add this flag, right?
Thanks.
|
|
|
|
|
Yes, you will have to add this flag and possibly some more while using c# compiler from command line.
Vitaliy Tsvayer
Tikle
|
|
|
|
|
If you double-click the 'Properties' folder for a project in the Solution Explorer, then click on the Build tab, you will see two checkboxes:
'Define DEBUG constant', and 'Define TRACE constant'. If the TRACE one is checked, VS does it all for you, if unchecked, you get no trace.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
this is my first C# project so bear with me. Here is the code. HistoryDataView is part of Form1 and is set to public.
namespace LockOut
{
public partial class Utility : Form
{
public Form1 m_parent;
public Utility(Form1 frm1)
{
m_parent = frm1;
}
public static DataTable DeviceHistory()
{
OleDbConnection pcDataConn = DBConnection();
try
{
DataSet ds = new DataSet();
string SQL = "SQL Statement";
OleDbDataAdapter adapter = new OleDbDataAdapter();
adapter.SelectCommand = new OleDbCommand(SQL, pcDataConn);
adapter.Fill(ds);
DataTable dt = new DataTable();
dt = ds.Tables[0];
if (dt.Rows.Count < 1)
{
dt = null;
}
pcDataConn.Close();
return dt;
}
catch(Exception ex)
{
pcDataConn.Close();
DataTable dt = null;
Console.WriteLine(ex.Message.ToString());
return dt;
}
}
public static void UpdateDeviceHistory()
{
m_parent.HistoryDataView.DataSource = DeviceHistory();
}
}
------------------------------------------------------
namespace LockOut
{
public partial class Form1 : Form
{
private void Refresh_Click(object sender, EventArgs e)
{
Utility.UpdateDeviceHistory();
}
}
}
|
|
|
|
|
Any reason the Utility class is a form? I would make Utility a regular class and remove the UpdateDeviceHistory method. Then in Form1 i would do this:
HistoryDataView.DataSource = Utility.DeviceHistory();
|
|
|
|
|
That is actually how I had it running initially within Form1. But I have another method within the Utility Class That logs the transactions and I wanted to be able to just update the datagridview after every log, so I would still need to use it from this class. I just turned it into a button click for testing. I hope this makes sense.
|
|
|
|
|
Not a very good idea to do that. But if thats what you want to do, you would have to make the m_parent static.
|
|
|
|