|
Hi!
I'm testing the filecopier application to move, copy, delete...files from one directory to another directory. But when i write the nested class FileComparer in class frmFileCopier to compare 2 filelist, it has an error:
Error1 'FileCopier.Form1.FileComparer' does not implement interface member 'System.Collections.Generic.IComparer<System.IO.FileInfo>.Compare(System.IO.FileInfo, System.IO.FileInfo)'.
Anyone helps me?
Thanks
The code
public class FileComparer : IComparer<FileInfo>
{
public int Compare(FileInfo file1, FileInfo file2)
{
if ( file1.Length > file2.Length )
{
return -1;
}
if ( file1.Length < file2.Length )
{
return 1;
}
return 0;
}
public bool Equals(FileInfo x, FileInfo y) {
throw new NotImplementedException( );
}
public int GetHashCode(FileInfo x) {
throw new NotImplementedException( );
}
}
|
|
|
|
|
assuming you have all the necessary using statements, that code looks fine by me.
Of course, as is, all it may help you achieve is sort a collection of FileInfo by file length.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Can you show us all the code from that file? I suspect there is some sort of name clash or something funky like that. The class as it is seems fine.
|
|
|
|
|
I found that i had some mistakes in early code. The class is fine.
Thanks for answers!
|
|
|
|
|
Hi all,
I've been trying to determine a good reason why one would use .TableName when the name of the DataTable variable is required anyway and .TableName is optional. Seems that having spent 10 minutes googling, gave me good enough reason to post here what seems like should be an easy question to answer......
I'm assuming it is the same type of situation one would encounter using ProEngineer (CAD). One could name a part with its part name (which would be the file name) and also have an optional "common name". So you could have 012569.prt which has a common name of Bolt. However, in my opinion, have different nomenclature for the same item is usually a "state of confusion" waiting to happen.
Thanks!
|
|
|
|
|
Remember that a DataTable was originally introduced as part of a DataSet, which allows a hierarchical linkage of tables (or you could just bundle several tables together in one if you liked). The TableName allows you to do things like search for the table in the DataSet.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
0) In case of a collection of them.
1) For when one is passed into a method.
etc.
|
|
|
|
|
You can't do that with the variable?
|
|
|
|
|
|
PIEBALDconsult wrote: Try it.
Yes, I knew this would be coming. One can certainly add a table to either a collection or use it in a method without having a formal name (but I don't think that is what you meant, is it)
public class Tables
{
public DataTable tblTest1;
public DataTable tblTest2;
public DataSet dsTables;
public Tables()
{
dsTables = new DataSet();
tblTest1 = new DataTable();
tblTest2 = new DataTable();
dsTables.Tables.Add(tblTest1);
dsTables.Tables.Add(tblTest2);
}
public void ShowTables()
{
DataTableCollection tables = this.dsTables.Tables;
foreach (DataTable tbl in tables)
Console.WriteLine(tables.IndexOf(tbl).ToString());
}
}
public static class Program
{
static int Main(string[] args)
{
Tables coll = new Tables();
coll.ShowTables();
Console.WriteLine();
Console.ReadLine();
return 0;
}
}
granted, having the foreach execute on
Console.WriteLine(tbl.TableName);
seems a bit more useful at first glance, so I guess I have my answer.........
|
|
|
|
|
Hi
I'm creating a desktop application for an old age home as a B.Tech project. This app needs to serve as a portal where users log in once to the application, and from there on gain access to their facebook and email accounts. When users decide to access Facebook, it shouldn't ask them for login details again, it should simply sign them in using a single sign on approach. I'm storing all my users' details (incl. Facebook email addresses and passwords) in a SQL 2008 database. And I'm using the Facebook Developer Toolkit from Codeplex[^] to create this desktop facebook application. Any hints on how I would proceed?
|
|
|
|
|
I'm not really sure what your question is here. It sounds like you've got the basics of a design sorted there. What exactly do you need help/advice with?
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
In simple terms; How would I get users to log in to facebook using their facebook information from the database? Without being hassled by a facebook login page? Almost like automatically feeding login information into the facebook website (if I can use that as an example).
|
|
|
|
|
Remember that a web page just transmits data over HTTP. All you'll need to do is simulate the sending of that information for them.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
I'm guessing I need to use HTTP POST and GET requests here? I'm not very familiar with these. Also, I'm using a desktop application with a WebBrowser control, so I would probably need to use WebRequest.Create ?
|
|
|
|
|
Please tell me how I would do this? Would I use WebRequest to construct a custom request?
|
|
|
|
|
I've created a few ASP.NET Web Service Applications. When you create one, it sets an attribute above the main service class which has a property, Namespace, that gets defaulted to http://tempuri.org/. According to MSDN, that default namespace should be changed:
It is highly recommended that this default namespace, which is http://tempuri.org, be changed before the XML Web service is made publicly consumable. This is important because the XML Web service must be distinguished from other XML Web services that might inadvertently use the namespace as the default (<http://tempuri.org/>).
What I want to know is the real purpose of this namespace and why it is important. How does that namespace help distinguish services? Is it if they are installed to the same folder on the server, it will prevent a clash of some sort? Don't you still need to specify the location of the service in any web service requests (e.g., "mydomain.com/Service1.asmx" or "mydomain.com/Service2.asmx")? And shouldn't that prevent any clashes?
Any illumination you could provide would be appreciated.
|
|
|
|
|
Perhaps this[^] (from tempuri.org) might help to explain why.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Not really.
|
|
|
|
|
Hi,
having wondered about this myself, I don't know, whether I can provide real illumination, but at least I can share my thougts about it.
I'm sure, that the EndpointAddress is not really suitable for identifying the service. In any network such a service can be addressed in at least two or three ways:
1. http://mydomain.com/myservice.asmx
2. http://13.13.200.7/...
and eventually
3. http:/mydomain.dyndns.org/...
There is no reason, to interpret the addressed service in different ways. Furthermore there might be 'copies' of the service in load balancing environments. So, the ony way to identify the service correct is via the namespace - as you do in C# and other languages.
The provided namespace does not free you from specifiying the location. In fact you can provide anything (maybe regarding some naming rules) as a namespace - even if it doesn't exist.
Cheers
Jürgen
|
|
|
|
|
Hello my friends. After thinking a lot about what to do for my Senior project, I decided to work on an application which will have, Chatting system, VOIP, File transfer, and if possible Video Conferencing. My friends and I planned to do the system for INTRANET System only. It is because we thought it will be more difficult to do it using internet. By the way, do you think broadening our scope to internet system rather than intranet system will need an agreement between the Internet Service Provider? That is what we are afraid of.
If it is in intranet system, we have planned to use one Server in the network and as many as clients, so they will have static IP address and it will be easy to identify who logs in or out every time once that IP is registered on the server. But how is that implemented on internet system? We have no clue about it.
Please give me some links and other suggestions to start our project. Although, we have tried to see some applications like Video Conferencing and VOIP in the code project’s articles. If there are any, please help us.
Thank you.
|
|
|
|
|
Hello,
I am using VS 2008 (C#) and I am running what would seem to be a very simple query to identify a users activity on a client server network. I am trying to extract a single value from a data table, but I am getting an error that I cannot understand. It seems so simple that I am baffled by the error. Here is the error and the code that generated it.
the error: {"Must declare the scalar variable \"@UserId\"."}
the code:
SqlConnection Conn = new SqlConnection(CONNSTR);
try
{
string Sql = "SELECT [IsActive] FROM SqlCodeGen " +
"WHERE [UserId] = @UserId AND [RegNumber] = @RegNumber AND [UnlockCode] = @UnlockCode ";
SqlCommand Comm = new SqlCommand(Sql, Conn);
Comm.CommandType = CommandType.Text;
Comm.Parameters.Clear();
Comm.Parameters.AddWithValue("@UserId", theUser );
Comm.Parameters.AddWithValue("@UnlockCode", theUnlockCode );
Comm.Parameters.AddWithValue("@RegNumber", theRegNumber );
SqlDataAdapter da = new SqlDataAdapter(Sql, Conn);
DataSet ds = new DataSet();
da.Fill(ds);
This is where the error occurs. Now, the parameter is clearly defined and a step by step evaluation shows that it is not null. If I remove all the parameters, the code block runs fine. If I remove just the error parameter, the next one reports the same issue. I do not understand why the SQL call does not see the parameters. Thank you in advance...Pat
ps: If I remove the parameters and hard code the variables into the query, it works perfect (ex: + "'" + theUser + "'")....but I hate the way it looks and I want to know why the correct way does not work!
|
|
|
|
|
You created the SqlCommand comm. You set it up perfectly.
Then, you create the SqlDataAdapter and just send it the SQL. You didn't tell the SqlDataAdapter anything about Comm.
try
SqlDataAdapter da = new SqlDataAdapter(Comm);
|
|
|
|
|
Thank you for your answer as well. I appreciate your time and have marked it as correct. I see you work for the NOAA. My favorite place on the planet is across the street from the NOAA headquarters in Pacific Grove, California. Best Regards, Pat
|
|
|
|
|
You create a command Comm and don't use it for your adapter. That's why it cannot find the parameter.
You should use this overload instead of new SqlDataAdapter(Sql, Conn); :
http://msdn.microsoft.com/en-us/library/awzk4kc1(v=VS.100).aspx[^]
In your case:
new SqlDataAdapter(Comm);
Die Energie der Welt ist konstant. Die Entropie der Welt strebt einem Maximum zu.
|
|
|
|