First you need to load the file into a stream
FileStream fileStream = new FileStream(@"d:\\Del\7\\SS 65.mp3", FileMode.Open)
Then convert it into a byte[]
byte[] mp3Byte = Mario.streamToByteArray(fileStream,1024)
);
here is the streamtobytearray method
public static byte[] streamToByteArray(Stream stream, int initialLength)
{
if (initialLength < 1)
{
initialLength = 32768;
}
byte[] buffer = new byte[initialLength];
int read = 0;
int chunk;
while ((chunk = stream.Read(buffer, read, buffer.Length - read)) > 0)
{
read += chunk;
if (read == buffer.Length)
{
int nextByte = stream.ReadByte();
if (nextByte == -1)
{
return buffer;
}
byte[] newBuffer = new byte[buffer.Length * 2];
Array.Copy(buffer, newBuffer, buffer.Length);
newBuffer[read] = (byte)nextByte;
buffer = newBuffer;
read++;
}
}
byte[] ret = new byte[read];
Array.Copy(buffer, ret, read);
return ret;
}
Then send it to the db as a field