Hi everyone,
In C#, is there a easy way of display files (ie. mp3 files) to a datagrid?
If someone can provide me with some code, or advice I would appreciated it.
Thanks in advance.
MikeY 4 1503
MikeY,
What do you mean to a datagrid? A datagrid is for tabular data, whereas
an MP3 is an audio file. They are incompatable.
Or do you mean a file listing? In this case, you should be able to use
the Directory object, setting the data source to the return value from the
static GetFiles method (since it returns an array of strings).
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"MikeY" <mi*******@yaho.com> wrote in message
news:RH*******************@news20.bellglobal.com.. . Hi everyone,
In C#, is there a easy way of display files (ie. mp3 files) to a datagrid? If someone can provide me with some code, or advice I would appreciated it.
Thanks in advance.
MikeY
Hi Ncholas,
Thanks for replying. I'm trying to display my mp3 files that reside in a
folder, then display all mp3 files within that folder in a datagrid. below
is a sample of my code, but it is just displaying the last file and not all
of them.
private Item[] items = new Item[]{};
protected class Item
{
public Item(string text)
{
m_text = text;
}
public string Text
{
get
{
return m_text;
}
}
private string m_text;
}
private void btnRetrieve_Click(object sender, System.EventArgs e)
{
System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(@"C:\Documents
and Settings\MikeYAdmin\Desktop\Music 1");
DirectoryInfo[] myDirectory = dir.GetDirectories();
FileInfo[] myInfo = dir.GetFiles();
foreach(System.IO.FileInfo fi in myInfo)
{
items = new Item[]{new Item(fi.Name)};
}
this.dGridTest.SetDataBinding(items, null);
}
MikeY
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:eu**************@TK2MSFTNGP10.phx.gbl... MikeY,
What do you mean to a datagrid? A datagrid is for tabular data, whereas an MP3 is an audio file. They are incompatable.
Or do you mean a file listing? In this case, you should be able to use the Directory object, setting the data source to the return value from the static GetFiles method (since it returns an array of strings).
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"MikeY" <mi*******@yaho.com> wrote in message news:RH*******************@news20.bellglobal.com.. . Hi everyone,
In C#, is there a easy way of display files (ie. mp3 files) to a datagrid? If someone can provide me with some code, or advice I would appreciated it.
Thanks in advance.
MikeY
the problem is here
foreach(System.IO.FileInfo fi in myInfo)
{
items = new Item[]{new Item(fi.Name)}; //only the last FileInfo is
preserved
}
this is what you need to do:
items = new Item[myInfo.Length];
int i = 0;
foreach(System.IO.FileInfo fi in myInfo)
{
items[i] = new Item(fi.Name);
i++;
}
"MikeY" <mi*******@yaho.com> wrote in message
news:0m*******************@news20.bellglobal.com.. . Hi Ncholas,
Thanks for replying. I'm trying to display my mp3 files that reside in a folder, then display all mp3 files within that folder in a datagrid. below is a sample of my code, but it is just displaying the last file and not
all of them. private Item[] items = new Item[]{};
protected class Item { public Item(string text) { m_text = text; } public string Text { get { return m_text; } } private string m_text; }
private void btnRetrieve_Click(object sender, System.EventArgs e) { System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(@"C:\Documents and Settings\MikeYAdmin\Desktop\Music 1");
DirectoryInfo[] myDirectory = dir.GetDirectories(); FileInfo[] myInfo = dir.GetFiles();
foreach(System.IO.FileInfo fi in myInfo) { items = new Item[]{new Item(fi.Name)}; }
this.dGridTest.SetDataBinding(items, null); }
MikeY
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in message news:eu**************@TK2MSFTNGP10.phx.gbl... MikeY,
What do you mean to a datagrid? A datagrid is for tabular data, whereas an MP3 is an audio file. They are incompatable.
Or do you mean a file listing? In this case, you should be able to
use the Directory object, setting the data source to the return value from
the static GetFiles method (since it returns an array of strings).
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"MikeY" <mi*******@yaho.com> wrote in message news:RH*******************@news20.bellglobal.com.. . Hi everyone,
In C#, is there a easy way of display files (ie. mp3 files) to a datagrid? If someone can provide me with some code, or advice I would appreciated it.
Thanks in advance.
MikeY
Thank you very much Lebesgue,
This is exactly what I was looking for and solved my problem.
Txs again
MikeY
"Lebesgue" <no****@spam.jp> wrote in message
news:uj*************@TK2MSFTNGP11.phx.gbl... the problem is here
foreach(System.IO.FileInfo fi in myInfo) { items = new Item[]{new Item(fi.Name)}; //only the last FileInfo is preserved }
this is what you need to do:
items = new Item[myInfo.Length]; int i = 0; foreach(System.IO.FileInfo fi in myInfo) { items[i] = new Item(fi.Name); i++; }
"MikeY" <mi*******@yaho.com> wrote in message news:0m*******************@news20.bellglobal.com.. . Hi Ncholas,
Thanks for replying. I'm trying to display my mp3 files that reside in a folder, then display all mp3 files within that folder in a datagrid. below is a sample of my code, but it is just displaying the last file and not all of them. private Item[] items = new Item[]{};
protected class Item { public Item(string text) { m_text = text; } public string Text { get { return m_text; } } private string m_text; }
private void btnRetrieve_Click(object sender, System.EventArgs e) { System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(@"C:\Documents and Settings\MikeYAdmin\Desktop\Music 1");
DirectoryInfo[] myDirectory = dir.GetDirectories(); FileInfo[] myInfo = dir.GetFiles();
foreach(System.IO.FileInfo fi in myInfo) { items = new Item[]{new Item(fi.Name)}; }
this.dGridTest.SetDataBinding(items, null); }
MikeY
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:eu**************@TK2MSFTNGP10.phx.gbl... > MikeY, > > What do you mean to a datagrid? A datagrid is for tabular data, > whereas an MP3 is an audio file. They are incompatable. > > Or do you mean a file listing? In this case, you should be able to use > the Directory object, setting the data source to the return value from the > static GetFiles method (since it returns an array of strings). > > Hope this helps. > > -- > - Nicholas Paldino [.NET/C# MVP] > - mv*@spam.guard.caspershouse.com > > "MikeY" <mi*******@yaho.com> wrote in message > news:RH*******************@news20.bellglobal.com.. . >> Hi everyone, >> >> In C#, is there a easy way of display files (ie. mp3 files) to a >> datagrid? If someone can provide me with some code, or advice I would >> appreciated it. >> >> Thanks in advance. >> >> MikeY >> > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: MikeY |
last post by:
Hi everyone,
In C#, is there a easy way of display files (ie. mp3 files) to a datagrid?
If someone can provide me with some code, or advice I would appreciated it.
Thanks in advance.
MikeY
|
by: cedced |
last post by:
Hello,
is it possible to access client files in VB.NET?
What?
I have doing that but it isn't good (VB.NET take file on pc server and not
on pc client):
(thanks)
Dim fichier As StreamReader
...
|
by: TK |
last post by:
I have a file upload control to allow a user to select/upload a file
to the server. They need to upload x number of files in one shot
because they have to confirm that they are uploading x number...
|
by: Hrvoje Vrbanc |
last post by:
Hello,
this is a problem I came upon while building a site based on MCMS 2002 but
it's not strictly MCMS-oriented:
I have a page that displays a certain content in presentation mode but when
an...
|
by: JenHu |
last post by:
hi,
I have a datagrid in my asp.net application, I am using vb.net
language.
I want to have my last column as a link column, link to text file.
The link path is "c:\Temp\" & F_File_Name, which...
|
by: Øyvind Isaksen |
last post by:
Hi,
I have made a code that list all files in a directory on the server.
It works fine, but I need to modify the filename (remove the 7 first char in
the name) that is displayed in the datagrid....
|
by: Øyvind Isaksen |
last post by:
I have a datagrid that displays all files in a folder. It works good, but I
need a extra column with a link for choosing image.
As shown in the code below I have made an ItemTemplate for this, and...
|
by: hott5hotj |
last post by:
Hi guys,
I've been working on a project to record video and audio using a standard webcam and microphone. I have been given the basic coding and have it running using wowza media server and apache....
|
by: Avedo |
last post by:
Hello!
I have a form application with a DataGridView, and an Save/Delete and Cancel button. When the application is opened, it is supplied an XML file that may or may not exist, and display the...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |