|
I need a sorted array data structure in my program and would like to know about the built in support for this in C#.
I looked into the System.Collections class and found a SortedList class, but this one doesn't allow duplicate keys.
If there isn't one, I might have to write one utlizing the IList interface.
Another option was to write a class that contained the ArrayList class and used the BinarySearch() method to maintain a sorted array.
Any comments would be helpful.
|
|
|
|
|
Think this bit of code might do what you’re looking for(sortable list), but I’m new to C# so there is probably a simpler or better way of doing this
//myArrayList is array of FileSystemInfo
myArrayList.Sort(new FileComparer());
public class FileComparer : IComparer
{
public int Compare(object a, object b)
{
FileSystemInfo o1 = (FileSystemInfo)a;
FileSystemInfo o2 = (FileSystemInfo)b;
return o1.Name.CompareTo(o2.Name);
}
}
|
|
|
|
|
Thanks, but this is a method to sort a list. I am looking for a Sorted List data structure. This would keep the list sorted as items are added to the list.
I am actually in the process of writing one.
A signature always reveals a man's character and sometimes even his name.
|
|
|
|
|
Hey,
How can i put a powerpoint presentation in a Windows Form?
I'm using Office XP
Thanks
Vanclei Matheus
Brazil
MSN Msgr - vmatheus@msn.com
|
|
|
|
|
My MainForm will receive a WM_DEVICECHANGE message from system.
I want to handle the message in the application.
And the MessageQueue is unavailable in my system.
I want to do someting when i recieve the message.
how to do?
Thanks for your advice.
|
|
|
|
|
You will need to override the WndProc method:
protected override void WndProc(ref System.Windows.Forms.Message m)
{
<br>
base.WndProc(ref m);
}
Nick Parker
|
|
|
|
|
Hello Friends,
In my application, I am showing Internet Explorers favourites. So, I am able to show all the shortcuts present in Internet Explorer's 'Favourite' Folder.
After clicking on that shortcut, Internet explorer should open.
I'm using System.Diagonostics.Process.Start(url) for this which is working fine.
Now my problem is , how can I get the url of the favourite file clicked, so that I can pass it in Process.Start(url) method.
Has anybody having any idea.
Thanks in Advance.
Pranoti
|
|
|
|
|
what about reading the contents of the file:
this is an example of a file:
[DEFAULT]
BASEURL=http://www.artistasdelanada.org/
[InternetShortcut]
URL=http://www.artistasdelanada.org/
Modified=A0D5D3661CB7C00142
Hope this helps.
Andres Manggini.
Buenos Aires - Argentina.
|
|
|
|
|
how to monitor any directory change that happened in a computer.
for example: wo can get a notice when you create a new directory or delete a directory.
|
|
|
|
|
If you are working with an NT environment you can use the FileSystemWatcher class; just point one at the root of all drives you're interested in and follow the documentation for the proper settings (Filter = "", call WaitForChanged() with proper WatcherChangeTypes, etc).
If you aren't working in a pure NT environment you could take a dirty approach and have a timer scan the directory tree for new/missing directories; since you aren't including files this should take *too* long, but it isn't something I would set to run very often.
HTH,
James
|
|
|
|
|
|
Is there a way to conditionally compile code based on if its a debug or release build? Similar to #ifdef _DEBUG in MFC.
|
|
|
|
|
#if DEBUG should work. I think that one would have been best left as #ifdef myself (considering they left in #define and #undef)
HTH,
James
|
|
|
|
|
I´ve createad a remote class that is registered with singleton access mode, so that all the clients access the same class instance. I´ve set my object lifetime so that the object don´t get destroyed until my hosting app finishes. I´ve connected 3 clients to the remote component so far. My question is: if I start to connect a large number of clients (let´s say 100 or 200) in this singleton-access-object, will remoting maintain the same instance to all my clients or it will create other instances for performance reasons ?
Mauricio Ritter - Brazil
Sonorking now: 100.13560 Trank
The alcohol is one of the greatest enemys of man, but a man who flee from his enemys is a coward.
|
|
|
|
|
Mauricio Ritter wrote:
My question is: if I start to connect a large number of clients (let´s say 100 or 200) in this singleton-access-object, will remoting maintain the same instance to all my clients or it will create other instances for performance reasons ?
From what I've heard with other people's results it will keep the same object for the entire duration of your hosting app.
Now the problem; you need to be careful in that nothing you do while remoting takes up *all* the CPU time; I've seen numerous reports that once that happens new connections are either denied or ignored until the processor becomes free.
I've seen a few suggestions but since I haven't looked 'in depth' into remoting I'm going only from (shaky) memory. First was that you should use Asynch delegates where possible. That means if you're waiting for something to happen create a delegate that does the waiting and fire it asynchronously (Begin/EndInvoke).
Hope that helps,
James
|
|
|
|
|
James T. Johnson wrote:
Now the problem; you need to be careful in that nothing you do while remoting takes up *all* the CPU time; I've seen numerous reports that once that happens new connections are either denied or ignored until the processor becomes free.
Interesting... will it deny my connection on the function calls or in the object instantiation ?
James T. Johnson wrote:
I've seen a few suggestions but since I haven't looked 'in depth' into remoting I'm going only from (shaky) memory. First was that you should use Asynch delegates where possible.
Hmmm... that´s a possibility...
Mauricio Ritter - Brazil
Sonorking now: 100.13560 Trank
The alcohol is one of the greatest enemys of man, but a man who flee from his enemys is a coward.
|
|
|
|
|
James T. Johnson wrote:
First was that you should use Asynch delegates where possible
I just have a thought... if I create a delegate and more than one user have this delegate installed in their class instances... since I´m working with a singleton object, will all the users receive the delegate notification ?
Mauricio Ritter - Brazil
Sonorking now: 100.13560 Trank
The alcohol is one of the greatest enemys of man, but a man who flee from his enemys is a coward.
|
|
|
|
|
Upon further investigation it looks like you don't *need* to have a delegate after-all.
Something like this (psuedo-code)
private delegate void DoWorkDelegate(WorkArgs e);
public void DoWork(WorkArgs e)
{
DoWorkDelegate dwd = new DoWorkDelegate(DoWorkReal);
IAsyncResult ar = dwd.BeginInvoke(e
null, null);
ar.AsyncWaitHandle.WaitOne();
if( ar.IsCompleted )
{
wdw.EndInvoke(ar);
}
}
private void DoWorkReal(WorkArgs e)
{
} Uncompiled code, but so much for my psuedo-code
HTH,
James
|
|
|
|
|
Hi!
I need to use SMTP server to send mail ...
I am trying to use program written by Agus Kurniawan "Sending mail via SMTP.." posted on this site... Code looks to be just fine .. but I am receiving error exception :
TcpClient SmtpServ = new TcpClient(ServSMTP.Text,25); string Data;
byte[] szData;
try
{
// initialization
NetworkStream NetStrm = SmtpServ.GetStream();
StreamReader RdStrm= new StreamReader(SmtpServ.GetStream());
LogList.Items.Add(RdStrm.ReadLine());
On the last line of listed code it bombs :
Value cannot be Null
Parameter name: item
Any suggestions what am i doing wrong?
SMTP server that i am trying to access: mail.mycompany.com
Please help
|
|
|
|
|
Hi David,
is it possible that something is wrong with "LogList.Items"?
did you try this?
string tempResult = RdStrm.ReadLine();
Sebastian
|
|
|
|
|
David37 wrote:
LogList.Items.Add(RdStrm.ReadLine());
The problem is that streams return null when the end is reached.
What you need to do is put the value of RdStrm.ReadLine() in a temporary value, then only add the value if it isn't null.
James
|
|
|
|
|
Thanks a lot guys...
But ... James, how come i have null all the time ...
Then, if I am commenting those lines out ...I am getting next error :
"Unable to write data to the transport connection" ... so when i am tracing I am getting that even net stream gets null ... No stream ... like something is definitely wrong ... or i don't see something..
Any suggestions?
Maybe my problem is SMTP Server itself :
TcpClient SmtpServ = new TcpClient(ServSMTP.Text,25); ????
Code :
NetworkStream NetStrm = SmtpServ.GetStream();
StreamReader RdStrm= new StreamReader(SmtpServ.GetStream());
tempResult = RdStrm.ReadLine();
if (tempResult != null)
{
LogList.Items.Add(tempResult);
}
// say hello to server and send response into log report
Data = "HELLO server " + CRLF;
szData = System.Text.Encoding.ASCII.GetBytes(Data.ToCharArray());
NetStrm.Write(szData,0,szData.Length);
//LogList.Items.Add(RdStrm.ReadLine());
|
|
|
|
|
Hello all.
I don't know C#,(and english too!), I'm starting with .net.
I'd like to know if in C# is possible do these 2 things:
Read who(user or groups) have access permission to a specific file or folder
and how(read,write,execute).
Second, is possible access other usefull information stored in indexing server about a file like the Author,Comments,Version,Company ecc. ecc.
I have searched a class to do this in .NET Framework without success.
I don't need the solution but at least a little help how to start.
Thanks, thanks in advance!!!
Sergio Bertini
|
|
|
|
|
serberwww wrote:
Read who(user or groups) have access permission to a specific file or folder
and how(read,write,execute).
Second, is possible access other usefull information stored in indexing server about a file like the Author,Comments,Version,Company ecc. ecc.
I think for this purpose you have to use API.
For getting file attribute you can use FileAttributes class.
Mazy
"The more I search, the more my need
For you,
The more I bless, the more I bleed
For you."The Outlaw Torn-Metallica
|
|
|
|
|
API? with c# and .NET is possible?
mmm, with FileAttributes I can access all these properties:
Archive = 0x00000020,
Compressed = 0x00000800,
Device = 0x00000040,
Directory = 0x00000010,
Encrypted = 0x00004000,
Hidden = 0x00000002,
Normal = 0x00000080,
NotContentIndexed = 0x00002000,
Offline = 0x00001000,
ReadOnly = 0x00000001,
ReparsePoint = 0x00000400,
SparseFile = 0x00000200,
System = 0x00000004,
Temporary = 0x00000100,
I'd like extract other usefull info in the file that
are also indexed by the index server.
How?
Sergio Bertini
|
|
|
|