•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C# section within the Software Development category of DaniWeb, a massive community of 374,445 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,757 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C# advertiser:
Views: 5606 | Replies: 26 | Solved
![]() |
ok, so i have been working on a program that i call "Sharppad" any ways it is a text editor. it has all teh basic functions. but it can also speak teh text you type. and convert text to .wav files. so you can listen to what you type. it also has a syntax editor. any ways i came too the part where i want it to print... and i get figure it out. i hvae tried code on the internet and it all just prints blank paper. any ideas?
Firefox
Ewido
Tune up windows
Get detailed system information
My Fixes
Member - Alliance of Security Analysis Professionals - Since 2006
Ewido
Tune up windows
Get detailed system information
My Fixes
Member - Alliance of Security Analysis Professionals - Since 2006
lol, yea pretty much, i still cant get it to read all the tags. but it copies the mp3 from the ipod to the harddrive. it provides a skin for itunes,(looks like an ipod functions like one) provides an interface for making contacts to put on teh ipod(vcards). and is also an id3 editor. so yea thats done. still trying to get it to read all the tags
EDIT: Hey r0ck if i put the code on here do you think you could help me get it to read all the tags in the directory in display them in the listbox

EDIT: Hey r0ck if i put the code on here do you think you could help me get it to read all the tags in the directory in display them in the listbox
Firefox
Ewido
Tune up windows
Get detailed system information
My Fixes
Member - Alliance of Security Analysis Professionals - Since 2006
Ewido
Tune up windows
Get detailed system information
My Fixes
Member - Alliance of Security Analysis Professionals - Since 2006
o and r0ck one more question how could i let the user choose between mp4 and pm3 cuz i try to declarte the textbox as teh file type. but it wont work? maybe a whole new fileType(filetype2) or an if else statement?????
Firefox
Ewido
Tune up windows
Get detailed system information
My Fixes
Member - Alliance of Security Analysis Professionals - Since 2006
Ewido
Tune up windows
Get detailed system information
My Fixes
Member - Alliance of Security Analysis Professionals - Since 2006
yea i was think bout radio buttons. but here is the weird thing. on my bro's ipod it read ALMOST all of them where as on mine and my dads it reads almost none....
i will post the code tommrow. its late now i gotta catch some z's
p.s
Thank you for all of your help. You have really taught me alot.
i will post the code tommrow. its late now i gotta catch some z's
p.s
Thank you for all of your help. You have really taught me alot.
Firefox
Ewido
Tune up windows
Get detailed system information
My Fixes
Member - Alliance of Security Analysis Professionals - Since 2006
Ewido
Tune up windows
Get detailed system information
My Fixes
Member - Alliance of Security Analysis Professionals - Since 2006
•
•
•
•
Originally Posted by tayspen
yea i was think bout radio buttons. but here is the weird thing. on my bro's ipod it read ALMOST all of them where as on mine and my dads it reads almost none....
i will post the code tommrow. its late now i gotta catch some z's
p.s
Thank you for all of your help. You have really taught me alot.
Ok, here is teh code...Keep in mind i am trying to backup the songs off my ipod onto my harddrive. I got this down. but when it copies it comes out with the weird names like QEYX i want it to read the id3 tags as it copies and spits them out with good names. i also need to be able to coopy mp4's out to.( i think i can do that) what i reallly n eed help on is the id3 part. anywho here it is.
the first thing that i will do is press a browse button that will bring up a folerbrowser.....
folderBrowserDialog1.ShowDialog(); //the textbox2 text is = to the folderbrowser selected index
textBox2.Text = folderBrowserDialog1.SelectedPath;
then it displays in the textbox, the filename.
From there its as easy as pressing the cop button..... this is the code for when it is pressed.....
private void button1_Click(object sender, EventArgs e)
{
try
{
string sourceDir = textBox1.Text + "\\iPod_Control\\Music";//add this to the drive that the user typed in (sets up the source file)
string targetDir = folderBrowserDialog1.SelectedPath; //show them the browser there directory = target
foreach (string d in Directory.GetDirectories(sourceDir))
{
foreach (string f in Directory.GetFiles(d, fileType))
{
MessageBox.Show("Please be patient process may take a while", "Please wait");//Notify the user
label2.Visible = true;//label2 now visible upon button click
File.Copy(f,
targetDir + "\\" + new FileInfo(f).Name, //Attempt copy
false);
}
}
}
Here is teh Read(); part. i tried puting Read(); in a few places. (no dice)
public void Read()
{
// Read the 128 byte ID3 tag into a byte array
FileStream oFileStream;
oFileStream = new FileStream(this.filename, FileMode.Open);
byte[] bBuffer = new byte[128];
oFileStream.Seek(-128, SeekOrigin.End);
oFileStream.Read(bBuffer, 0, 128);
oFileStream.Close();
// Convert the Byte Array to a String
Encoding instEncoding = new ASCIIEncoding(); // NB: Encoding is an Abstract class
string id3Tag = instEncoding.GetString(bBuffer);
// If there is an attched ID3 v1.x TAG then read it
if (id3Tag.Substring(0, 3) == "TAG")
{
this.Title = id3Tag.Substring(3, 30).Trim();
this.Artist = id3Tag.Substring(33, 30).Trim();
this.Album = id3Tag.Substring(63, 30).Trim();
this.Year = id3Tag.Substring(93, 4).Trim();
this.Comment = id3Tag.Substring(97, 28).Trim();
// Get the track number if TAG conforms to ID3 v1.1
if (id3Tag[125] == 0)
this.Track = bBuffer[126];
else
this.Track = 0;
this.GenreID = bBuffer[127];
this.hasTag = true;
// ********* IF USED IN ANGER: ENSURE to test for non-numeric year
}
else
{
this.hasTag = false;
}
}
(i might have trimmed some out so if u see somthing missing lemme no)
maybe i should update teh mp3's as there being cbacked up
public void updateMP3Tag()
{
// Trim any whitespace
this.Title = this.Title.Trim();
this.Artist = this.Artist.Trim();
this.Album = this.Album.Trim();
this.Year = this.Year.Trim();
this.Comment = this.Comment.Trim();
// Ensure all properties are correct size
if (this.Title.Length > 30) this.Title = this.Title.Substring(0, 30);
if (this.Artist.Length > 30) this.Artist = this.Artist.Substring(0, 30);
if (this.Album.Length > 30) this.Album = this.Album.Substring(0, 30);
if (this.Year.Length > 4) this.Year = this.Year.Substring(0, 4);
if (this.Comment.Length > 28) this.Comment = this.Comment.Substring(0, 28);
// Build a new ID3 Tag (128 Bytes)
byte[] tagByteArray = new byte[128];
for (int i = 0; i < tagByteArray.Length; i++) tagByteArray[i] = 0; // Initialise array to nulls
// Convert the Byte Array to a String
Encoding instEncoding = new ASCIIEncoding(); // NB: Encoding is an Abstract class // ************ To DO: Make a shared instance of ASCIIEncoding so we don't keep creating/destroying it
// Copy "TAG" to Array
byte[] workingByteArray = instEncoding.GetBytes("TAG");
Array.Copy(workingByteArray, 0, tagByteArray, 0, workingByteArray.Length);
// Copy Title to Array
workingByteArray = instEncoding.GetBytes(this.Title);
Array.Copy(workingByteArray, 0, tagByteArray, 3, workingByteArray.Length);
// Copy Artist to Array
workingByteArray = instEncoding.GetBytes(this.Artist);
Array.Copy(workingByteArray, 0, tagByteArray, 33, workingByteArray.Length);
// Copy Album to Array
workingByteArray = instEncoding.GetBytes(this.Album);
Array.Copy(workingByteArray, 0, tagByteArray, 63, workingByteArray.Length);
// Copy Year to Array
workingByteArray = instEncoding.GetBytes(this.Year);
Array.Copy(workingByteArray, 0, tagByteArray, 93, workingByteArray.Length);
// Copy Comment to Array
workingByteArray = instEncoding.GetBytes(this.Comment);
Array.Copy(workingByteArray, 0, tagByteArray, 97, workingByteArray.Length);
// Copy Track and Genre to Array
tagByteArray[126] = System.Convert.ToByte(this.Track);
tagByteArray[127] = System.Convert.ToByte(this.GenreID);
// SAVE TO DISK: Replace the final 128 Bytes with our new ID3 tag
FileStream oFileStream = new FileStream(this.filename, FileMode.Open);
if (this.hasTag)
oFileStream.Seek(-128, SeekOrigin.End);
else
oFileStream.Seek(0, SeekOrigin.End);
oFileStream.Write(tagByteArray, 0, 128);
oFileStream.Close();
this.hasTag = true;
}
So that bout some that up. thanks r0ck for any ideas that you might have
p.s
i have tried the previous ideas(i just may have switched some things around or put it back hw it was,, so if it looks like i havnt tried any of your previous ideas...i have)
Firefox
Ewido
Tune up windows
Get detailed system information
My Fixes
Member - Alliance of Security Analysis Professionals - Since 2006
Ewido
Tune up windows
Get detailed system information
My Fixes
Member - Alliance of Security Analysis Professionals - Since 2006
•
•
Join Date: Dec 2003
Posts: 55
Reputation:
Rep Power: 5
Solved Threads: 6
Hi, i think yo didn't get the point of the Read() function ...Read is in fact a member function of a class called ID3v1.
I gave a you a link to a this complete class in another thread, so what you do is the following, copy-paste the whole code to a file called ID3v1.cs , and then you incorporate that file into your project, then after that you call it like this:
I didn't test this code, so there might be some bugs.
I gave a you a link to a this complete class in another thread, so what you do is the following, copy-paste the whole code to a file called ID3v1.cs , and then you incorporate that file into your project, then after that you call it like this:
foreach (string f in Directory.GetFiles(d, fileType))
{
MessageBox.Show("Please be patient process may take a while", "Please wait");//Notify the user
label2.Visible = true;//label2 now visible upon button click
// Now try to read tags from the file to copy
ID3v1 mp3Tag = new ID3v1(f);
File.Copy(f, targetDir+"\\"+mp3Tag.Artist+"_"+mp3Tag.Title+new FileInfo(f).Extension, false);
//........
}I didn't test this code, so there might be some bugs.
•
•
•
•
Originally Posted by r0ckbaer
Hi, i think yo didn't get the point of the Read() function ...Read is in fact a member function of a class called ID3v1.
I gave a you a link to a this complete class in another thread, so what you do is the following, copy-paste the whole code to a file called ID3v1.cs , and then you incorporate that file into your project, then after that you call it like this:
foreach (string f in Directory.GetFiles(d, fileType)) { MessageBox.Show("Please be patient process may take a while", "Please wait");//Notify the user label2.Visible = true;//label2 now visible upon button click // Now try to read tags from the file to copy ID3v1 mp3Tag = new ID3v1(f); File.Copy(f, targetDir+"\\"+mp3Tag.Artist+"_"+mp3Tag.Title+new FileInfo(f).Extension, false); //........ }
I didn't test this code, so there might be some bugs.
lemme gixe it a go..... be back soon
Firefox
Ewido
Tune up windows
Get detailed system information
My Fixes
Member - Alliance of Security Analysis Professionals - Since 2006
Ewido
Tune up windows
Get detailed system information
My Fixes
Member - Alliance of Security Analysis Professionals - Since 2006
ok so i tried this is is the exact code under the rip button
EDIT: just took off catch statement. the error was that the file - already exists...
now it copies one song with the file name -
and then it shows me my catch form if somthing goes wrong.....
i hadded that ID# form and everything...
private void button1_Click(object sender, EventArgs e)
{
try
{
string sourceDir = textBox1.Text + "\\iPod_Control\\Music";//add this to the drive that the user typed in (sets up the source file)
string targetDir = folderBrowserDialog1.SelectedPath; //show them the browser there directory = target
foreach (string d in Directory.GetDirectories(sourceDir))
{
foreach (string f in Directory.GetFiles(d, fileType))
{
label2.Visible = true;//label2 now visible upon button click
// Now try to read tags from the file to copy
ID3v1 mp3Tag = new ID3v1(f);
File.Copy(f, targetDir + "\\" + mp3Tag.Artist + "_" + mp3Tag.Title + new FileInfo(f).Extension, false);
//........
}
}
}
catch
{
frmerror frm = new frmerror();
frm.ShowDialog(this); // show notes (EDIT: notes canceled now show about)
frm.Dispose();
}
}
EDIT: just took off catch statement. the error was that the file - already exists...
now it copies one song with the file name -
and then it shows me my catch form if somthing goes wrong.....
i hadded that ID# form and everything...
Firefox
Ewido
Tune up windows
Get detailed system information
My Fixes
Member - Alliance of Security Analysis Professionals - Since 2006
Ewido
Tune up windows
Get detailed system information
My Fixes
Member - Alliance of Security Analysis Professionals - Since 2006
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb C# Marketplace
Other Threads in the C# Forum
- Previous Thread: Create buttons at runtime
- Next Thread: how do i update to Access db?



Linear Mode