|
I didn't realize that FAT/FAT32 weren't ordered. My bad.
Implement a IComparer class then. You can change the compare method to sort however you want, by date if you wanted. Maybe even pass in an Enum of sort options.
using System;
using System.Collections;
using System.IO;
public class CompareFileInfo : IComparer
{
int IComparer.Compare(object first, object second)
{
FileInfo file1 = (FileInfo)first;
FileInfo file2 = (FileInfo)second;
return string.Compare(file1.Name, file2.Name);
}
}
public class MyClass
{
public static void Main()
{
DirectoryInfo dir = new DirectoryInfo(@"c:\");
FileInfo[] files = dir.GetFiles();
Array.Sort(files, new CompareFileInfo());
Array.Reverse(files);
foreach(FileInfo file in files)
{
Console.WriteLine(file.Name);
}
}
}
|
|
|
|
|
Use the following line of code to get list of files.
string[] files = Directory.GetFiles(@"C:\docs");
now iterate in your own fashion to descending order.
Balaji
|
|
|
|
|
Hi,
I have a table "Inventory" that has ID, ItemNumber, Description etc fields and the user can edit these via a datagrid.
The ItemNumber is also used in another table "SalesHistory".
What I want to do is update the ItemNumber in "SalesHistory" once the user has elected to do so before saving the ItemNumber change in the "Inventory" table to the database.
The problem I am having is determining the "old" value so I can update the "SalesHistory" table.
I don't want to call the database again to find the old value by matching ID's but it seems I have no alternative.
Suggestions please ...
Glen Harvy
|
|
|
|
|
Two ideas, check if there is an event for just before an something is changed (i know text boxes have it ) and do everything there (you can see what the new value is from the eventargs).
Or make a custom control that inherits a datagrid, and if you can, override the part where items are updated.
Sorry if i'm a little vague, but im off to bed, up early tomorrow
|
|
|
|
|
There's no obvious event that I can find (eg cellEnter) so I can store the value before it's changed.
Goodnight and thanks for your suggestions
Glen Harvy
|
|
|
|
|
I've played around a while and tested and tried a BUNCH of stuff about an icon. I've made an icon and added it to the solution explorer. Then, how do I get the icon to show up? Please help, I've honestly been doing some things to get better and dusted off the Dummies book! I know this is an easy question for most, but it gives me trouble! Thanks in advance.
|
|
|
|
|
What do you want to do with the icon?
Paul Marfleet
|
|
|
|
|
Well, I want to make it appear in the form's corner, but when I set it in the code, it fails, and when I set it in the form designer, another paper-like image replaces my icon.
|
|
|
|
|
You should be able to set the icon in the Form designer by clicking the '...' button against the Icon property and browsing to your icon file.
Paul Marfleet
|
|
|
|
|
That's what didn't work. It showed the icon next to it (mine, not the one it places), but when I start the program, it replaces it with the page-looking one... See?
|
|
|
|
|
Hi,
AFAIK there are two different icon issues:
1.
the application itself has an icon; it gets used by Windows Explorer; you set it as a project property.
2.
any form can have an icon; it is a Form property, that you can set through Visual Designer.
It also shows up in the task bar's button (if the Form shows in task bar).
BTW: if your Icon file holds more than one icon image (say at different sizes), which one
gets used depends on circumstances (e.g. small/large/detail view in Windows Explorer).
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
I still don't get how to show the icon.
|
|
|
|
|
"I want to make it appear in the form's corner"
that would be the Form.Icon property which you can set through Designer; there is no need
to add the icon file to the project explicitly, just open your Form Designer, choose
properties, and now hit the button at the right of the Icon property and choose.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
I did it, for the last time. BUT, when the program starts, it's icon is NOT the one I chose.
|
|
|
|
|
Point is, it doesn't work (or I'm being stupid). Will anyone please help?
|
|
|
|
|
what program did you use to create the icon?
Code pre-built is code that you don't have to build later.
|
|
|
|
|
|
I mean, how did you make the icon? The icon may not be the right color bit or might be the wrong size, so therefore when you run your program, it chooses a different icon.
Code pre-built is code that you don't have to build later.
|
|
|
|
|
Oh; I added a new icon file, which is in the solution explorer. Then, I set it as the icon and it doesn't work.
|
|
|
|
|
|
I know. It says next to where you choose the icon, in a little picture, the icon I made, but when I start up, it's totally different.
|
|
|
|
|
What size icon did you create ? There's a number of sizes, it sounds like the app is choosing a different icon size, and thus reverting to the default icon.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Well, I beleive it is 32 X 32...
|
|
|
|
|
No, the icon on your form is 16x16. CTRL-PrtScn will do a screen capture of your app, then you can paste into paint to work out things like that.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Icons on the form (and detail / listview in explorer) are 16*16. Try making it that size and see if you have any luck.
Also incase your interested, windows uses these icon sizes:
16*16
32*32
48*48
Just so you know
|
|
|
|