|
Post the part of your code that isn't working like you need it to, and explain exactly what you expect or need to get from it so I can help further.
Jeff
|
|
|
|
|
I am writing a small program in C# that has to count the number of image files and the number of text files in a single folder and to come up with a seperate value for each type of file. The code has to be general enough to accomodate changes to the number of image or text files in a given folder depending upon the designated path.
At present, my approach has been to specify the path via code such as @"C:\My Program\Folder";
Any help would be appreciated.
|
|
|
|
|
Read the first thread in the forum titled "How to get an answer to your question". Pay attention to item #2
|
|
|
|
|
if you know the file type, the easiest way is use Directory.GetFiles(path, "*.ext"); it will return a string array, you can get the file count using Properties of Length
|
|
|
|
|
Thank you so much.
As I said before, I am on this like you can't believe.
|
|
|
|
|
Then you can use System.Drawing.Imaging.ImageCodecInfo.GetImageEncoders(); to get all supported image format, or you could create your own image format array to loop the extension as I mention(and what you did).
|
|
|
|
|
You people are great!
I have solved much of the program's display requirements... thanks to all of your assistance and pointers.
|
|
|
|
|
You can use DirectoryInfo to get all files in a specific folder, you can also get it to only return files with specific file extensions, so look up how to use directoryinfo, and start making a list of all the file extensions that your image files have.
My current favourite word is: Waffle
Cheese is still good though.
|
|
|
|
|
Thank you so much.
I'm gonna be all over this like a fat kid on candy.
|
|
|
|
|
I store path of images in Sql Server Database.Now I want to display those images to DataList.How can I do that ?
nothing
|
|
|
|
|
Make the DataList use a second DataTable as the source for its info, instead of the one you read in from the DB. Note that I did not use a compiler to write this, so you will need to modify it as needed, but I think the logic should work.
// Assume the other dataTable is called "original"
// Perform this op as soon as you read the data from the DB
DataTable dt = new DataTable();
foreach (DataColumn dc in original.Columns) {
if (dc.Name == "WhateverYouCallTheImageColumn") {
dt.Columns.Add(new DataColumn(dc.Name, typeof(Bitmap)));
} else {
dt.Columns.Add(new DataColumn(dc.Name, dc.Type));
}
}
foreach (DataRow dr in original.Rows) {
DataRow newRow = new DataRow();
foreach (DataColumn dc in original.Columns) {
// populate newRow, opening the images when you arrive at that column
}
dt.AddRow(newRow);
}
DataView dv = new DataView(dt);
Jeff
|
|
|
|
|
I'm looking for any insight on how to modify the summary information of a file (title, subject, author etc.). I've looked through System.IO and can't seem to find anything that will do this. I want to do this for any type of file (primarily office docs and pdfs), so dsofile doesn't quite do the trick.
Thanks
|
|
|
|
|
This information (for office documents) is actually stored in OLE Structured Storage (as part of the file). The only way to modify this would be to either access the file direct or to use COM Interop with the Office applications.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
I can modify all of the properties for office docs using the dsofile.dll which isn't a problem. Is there a generic way to modify the file summary for any type of document, not just office docs?
|
|
|
|
|
I'm sure I just pointed out that the summary was stored in the file itself - i.e. wasn't easily accessible metadata. So, no. Different files types have their own ways of storing this information.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
File.SetCreationTime(); That kind of stuff?
Nevermind. I see you were talking about author, description, etc
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
|
Hi!
Is it possible to change the font in a console application?
Like iif I have a game where I pick up a megaphone, and want to have a webbding character that happens to look just like a megaphone. Is this possible?
thanks Daniel
Dan Steeve
|
|
|
|
|
Hi Dan,
I once did color changes on a Console app, that took some P/Invoke using the following
prototypes and definitions:
[DllImport("kernel32.dll")]
public static extern bool SetConsoleCtrlHandler(ConsoleControlHandler e, bool add);
[DllImport("kernel32.dll")]
public static extern IntPtr GetStdHandle(int nStdHandle);
[DllImport("kernel32.dll")]
public static extern bool SetConsoleTextAttribute(IntPtr windowHandle, int attrib);
[DllImport("KERNEL32.DLL")]
internal static extern int GetConsoleScreenBufferInfo (IntPtr hConsoleOutput,
ref CONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo);
public delegate bool ConsoleControlHandler(ConsoleControlEvent consoleEvent);
public enum ConsoleControlEvent {
CtrlC=0,
CtrlBreak=1,
CtrlClose=2,
CtrlLogoff=5,
CtrlShutdown=6}
public enum TextColor {
Black=0,
DarkBlue=1,
DarkGreen=2,
Brown=4,
DarkMagenta=5,
DarkYellow=6,
Gray=7,
Blue=9,
Green=10,
Cyan=11,
Red=12,
Magenta=13,
Yellow=14,
White=15,
Unknown=16
}
This should get you going.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Pssst, in the 2.0 Framework they added Console.BackgroundColor and Console.ForegroundColor. And there's an enum for ConsoleColor.
|
|
|
|
|
Well that is nice to know, thanks. If only they had provided that in time...
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
As far as I know, the only fonts allowed for Consoles is controlled by the following registry entry.
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Console\TrueTypeFont
Once the font has been added there, a reboot is required. But then, I have no clue how you actually change the font being used, but there's gotta be a Win32 API call somewhere you can p/invoke. I think Luc's examples might help you locate that.
Also, in the registry entry, it's not logical because the entry you're likely to see is:
0 REG_SZ Lucinda Console
You'd think oh, I just need to add:
1 REG_SZ Consolas
Nope, WRONG! You would add
00 REG_SZ Consolas
and a third one would be:
000 REG_SZ Courier
Yep, real intuitive.
|
|
|
|
|
Dear Sir,
I am facing one problem in DataGrid. i want to add many columns in DataGrid at runtime .because this is requirement of our applcation. i want to add around 25000 columns at runtime. but when i add columns at run time, application hang up or it will taking much much time to add columns in DataGrid. so any one suggest me the best solution of display 25000 columns in DataGrid
|
|
|
|
|
Do you mean 25,000 ROWS? I can't think of any reason a table would need 25,000 columns.
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
No sir, i mean 25000 columns . it is req. of our software
|
|
|
|