Yeah.. I wrote these two functions to serialize a file to send over a web service. They will do the trick for you.
public static bool UploadFile(string strPath, byte[] btFile)
{
try
{
FileStream objFileStream = new FileStream(strPath, FileMode.CreateNew, FileAccess.Write, FileShare.None);
objFileStream.Write(btFile, 0, btFile.Length);
objFileStream.Close();
}
catch (FieldAccessException e)
{
// write to application log
return false;
}
return true;
}
public static byte[] DownloadFile(string strFile)
{
byte[] btFile;
try
{
FileStream objFileStream = new FileStream(strFile, FileMode.Open, FileAccess.Read, FileShare.Read);
btFile = new Byte[objFileStream.Length];
objFileStream.Read(btFile, 0, (int) objFileStream.Length);
objFileStream.Close();
}
catch (Exception e)
{
return null;
}
return btFile;
}