|
thanx.
And I also what to detect current bandwidth. What could I do?
karanba
|
|
|
|
|
|
No. Bad. You can't ping someone else's website as part of your application or service unless you have an agreement with them. There is such a thing as a ping attack. ibm.com no longer responds to ping, for example, because people were using it in this way. If google decides to do the same, his app won't work anymore. Your solution is good if his app is noncommercial or not used by many people.
"Outside of a dog, a book is Man’s best friend. And inside of a dog, it’s too dark to read."
-Groucho Marx
|
|
|
|
|
how to copy one file from one path to another path (and over wight it ).
r00d0034@yahoo.com
|
|
|
|
|
You need to use the CopyTo() method of the FileInfo Class.
foreach (FileInfo file in filesInDirInfo)
{
file.CopyTo(newDirName);
}
david23g
|
|
|
|
|
I use a DataSet load a DBtable,and I want to know how many memory were used by the DataSet object.
sizeof keyword and System.Runtime.InteropServices.Marshel.SizeOf method can only be used for unmanaged objects.
how can I get a reference type object memory size???
lost my way
|
|
|
|
|
fftongzhi wrote:
how can I get a reference type object memory size???
You can do something like this:
DataSet ds = new DataSet();
IntPtr p = Marshal.StringToHGlobalAnsi(ds.ToString());
MessageBox.Show("Size: " + Marshal.SizeOf(p));
Marshal.FreeHGlobal(p);
[EDIT] On second thought, that is only giving you the size of a string . I will have to look into this.[/EDIT]
Nick Parker
You see the Standards change. - Fellow co-worker
|
|
|
|
|
convert a object to string and get the string size,I have also felt that is a way.But some object contents can not conver to string ,you can just try this
byte[] bytelist=new byte[10]{1,2,3,4,5,6,7,8,9,10};
bytelist.tostring()=="byte[]" not the realy things we want. "12345678910"
so tostring can not get the size of a ref object :$
my method is write the object in to a memory stream and get the stream.length.
I feel some silly about this way,but where is the right way??
you can not get a object memory size in .net??? It means I made a world but I don't know what is it like!!! my god!!!!!!!!!!!
lost my way
|
|
|
|
|
You could also try to serialize the object into a MemoryStream and get its size, but this has some drawbacks:
1. It's awful slow.
2. It will return a much bigger size than the real one, because it will include type info needed for the deserialization process.
3. It will only work on types marked [Serializable]
I see dumb people
|
|
|
|
|
Is that all the VM language have the same problem?
It also can not get a ref object size in java.
My god,we are in a unknowable world.
lost my way
|
|
|
|
|
|
Is that to say we need not to know the memory requirements of our application??? If we are faced with a memory useing limited project,what can we do ?
lost my way
|
|
|
|
|
|
What other solution would there be? An object could contain a reference to a reference to a ...
You have to at some point serialize it out to memory to get the complete size it takes up.
|
|
|
|
|
Hi
i'm doing a user control in C#, where i have textbox controles, when ever a textbox is clicked (when the event textBox1.Click is fired) i need to FIRE the this.Load event (not to call the this.Load event handler method!!!).
Because when i use this conrole in a form the event handler method will change.
Thanks a lot
PS: if you know how to do it on other .net languages tell me...it will be very helpful
|
|
|
|
|
1. Define an event:
public event EventHandler TextBoxClick;
2. Define a method to fire the event:
protected vitual void OnTextBoxClick(object sender, EventArgs e)
{
if (TextBoxClick != null) TextBoxClick(sender, e);
}
3. Fire the event from the associated event eg:
textBox1.Click += new EventHandler(Textboxclicked);
textBox2.Click += new EventHandler(Textboxclicked);
textBox3.Click += new EventHandler(Textboxclicked);
textBox4.Click += new EventHandler(Textboxclicked);
...
void Textboxclicked(object sender, EventHandler e)
{
OnTextBoxClick(sender, e);
}
4. Implemeted the TextBoxClick event on the form.
mControl.TextBoxClick += new EventHandler(methodtohandleevent);
There you have it! Merry Xmas
WebBoxes - Yet another collapsable control, but it relies on a "graphics server" for dynamic pretty rounded corners, cool arrows and unlimited font support.
|
|
|
|
|
I am relatively new to Windows forms and I wonder how could I detect that the mouse is still over the form if it moves
over a button or some other control on it?. The critical point is the border between a form and a child control. If I
use mouse enter and leave event for a moment the mouse is neither over the form or the control. In my case the whole
form flickers. How is this sort of event handling to be accomplished? I cannot find nothing that would give me a hint.
I would also like to know if the mouse is over the nonclient area of the form.
Thank you!
|
|
|
|
|
Hi,
How can I enumerate all network resources using C#?
I want to get list of a lan computers by IP or machine name.
|
|
|
|
|
The following is incomplete, but the part you need is there. It is based on code provided in a CP article by Leppie (sql server combo box, I think), refactored into a utility class with a few minor corrections.
public enum ServerTypes : uint
{
None = 0,
ALL = 0xFFFFFFFF,
WORKSTATION = 0x00000001,
SERVER = 0x00000002,
SQLSERVER = 0x00000004,
DOMAIN_CTRL = 0x00000008,
DOMAIN_BAKCTRL = 0x00000010,
TIME_SOURCE = 0x00000020,
AFP = 0x00000040,
NOVELL = 0x00000080,
DOMAIN_MEMBER = 0x00000100,
PRINTQ_SERVER = 0x00000200,
DIALIN_SERVER = 0x00000400,
XENIX_SERVER = 0x00000800,
NT = 0x00001000,
WFW = 0x00002000,
SERVER_MFPN = 0x00004000,
SERVER_NT = 0x00008000,
POTENTIAL_BROWSER = 0x00010000,
BACKUP_BROWSER = 0x00020000,
MASTER_BROWSER = 0x00040000,
DOMAIN_MASTER = 0x00080000,
SERVER_OSF = 0x00100000,
SERVER_VMS = 0x00200000,
WINDOWS = 0x00400000,
DFS = 0x00800000,
CLUSTER_NT = 0x01000000,
DCE = 0x10000000,
ALTERNATE_XPORT = 0x20000000,
LOCAL_LIST_ONLY = 0x40000000,
DOMAIN_ENUM = 0x80000000
}
public class ServerList
{
[DllImport("netapi32.dll")]
unsafe private static extern uint NetServerEnum([MarshalAs(UnmanagedType.LPWStr)] string ServerName,
uint level,
uint* bufptr,
uint prefmaxlen,
ref uint entriesread,
ref uint totalentries,
uint servertype,
[MarshalAs(UnmanagedType.LPWStr)] string domain,
uint resume_handle);
[DllImport("netapi32.dll")]
unsafe private static extern uint NetApiBufferFree([MarshalAs(UnmanagedType.AsAny)] object bufptr);
[System.Runtime.InteropServices.StructLayoutAttribute (LayoutKind.Sequential, CharSet=CharSet.Auto)]
private struct SERVER_INFO_101
{
public int dwPlatformID;
public System.IntPtr lpszServerName;
public int dwVersionMajor;
public int dwVersionMinor;
public int dwType;
public int lpszComment;
}
public ServerList()
{
}
public static string[] GetNtNodeNames(string ntDomainName)
{
return (GetServers(ntDomainName, (uint)(ServerTypes.SERVER | ServerTypes.WORKSTATION)));
}
public static string[] GetSqlServerNames(string ntDomainName)
{
return (GetServers(ntDomainName, (uint)(ServerTypes.SQLSERVER)));
}
public static string[] GetServers(string ntDomainName, uint serverTypemask)
{
string[] servers = new string[0];
string serverName = null;
string domainName = null;
if (ntDomainName != null)
if (ntDomainName.Length > 0)
domainName = ntDomainName;
uint level = 101, prefmaxlen = 0xFFFFFFFF, entriesread = 0, totalentries = 0;
uint resume_handle = 0;
uint stat = 0;
unsafe
{
IntPtr si = IntPtr.Zero;
SERVER_INFO_101* pTmp;
uint _serverType = serverTypemask;
try
{
stat = NetServerEnum(serverName, level, (uint *) &si, prefmaxlen, ref entriesread,
ref totalentries, (uint)_serverType, domainName, resume_handle);
if (stat == 0)
{
servers = new string[entriesread];
if ((IntPtr)(si) != IntPtr.Zero)
{
pTmp = (SERVER_INFO_101*)si;
for (int i = 0; i < entriesread; i++)
{
try
{
servers[i] = Marshal.PtrToStringAuto(pTmp->lpszServerName);
}
catch (Exception e)
{
throw e;
}
pTmp++;
}
}
}
}
catch (Exception e)
{
throw e;
}
finally
{
if (si != IntPtr.Zero)
stat = NetApiBufferFree(si);
}
return servers;
}
}
}
</small>
Hope this helps & Merry Xmas.
Some ideas are so stupid that only an intellectual could have thought of them - George Orwell
|
|
|
|
|
my previous post doesn't show up?
|
|
|
|
|
|
|
One of the reasons I can think of is that you don't want a programmer to break some important functionality.
For example:
sealed class RegulateControlRods
{
if (power > 10MW) LowerRods();
if (power < 5MW) RaiseRods();
}
or perhaps change its interface to other classes. For example:
public class RegulateControlRods
{
if (power > 10MW) LowerRods();
if (power < 5MW) RaiseRods();
}
public class HomerSimpsonNuclearPowerPlant : RegulateControlRods
{
if (power > 10MW) RunLikeHell();
if (power < 5MW) GoEatADohnut();
}
However, sealing things like "Point"???
Sometimes I think both C# and .NET were the result of some highschool student's finals project in Computer Science 101.
Marc
Help! I'm an AI running around in someone's f*cked up universe simulator. Sensitivity and ethnic diversity means celebrating difference, not hiding from it. - Christian Graus Every line of code is a liability - Taka Muraoka
|
|
|
|
|
|
|