tom jones

tom jones

  • NA
  • 18
  • 10.7k

CONVERTING BYTE TO DECIMAL

Feb 11 2014 2:52 PM

http://msdn.microsoft.com/en-us/library/aa326741%28v=vs.71%29.aspx[^]


//I WAS READING FROM THE ABOVE MICROSOFT LINK ABOUT CONVERTING FROM BYTE TO TO //DECIMAL IN C#, BUT I AM JUST NOT GETTING MY CODE TO WORK. I AM TRYING TO //CONVERT AN ARRAY OF BYTES TO AN ARRAY OF DECIMALS. THIS IS WHAT I AM //DOING..PLEASE KINDLY SEE BELOW.


<pre>using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Applica
{
class Program
{
static void Main(string[] args)
{
long Totbyte = 0;
string filePath = null;
DirectoryInfo da = new DirectoryInfo("C:\\Folder");
FileInfo[] Arr = da.GetFiles();

foreach (FileInfo ap in Arr)
{
Totbyte = ap.Length;
filePath = ap.FullName;
}

string temPath = Path.GetTempFileName();
byte[] data = new byte[Totbyte];

if (File.Exists(temPath))
{
data = File.ReadAllBytes(filePath);
File.WriteAllBytes(temPath, data);
}
decimal decVal;
int[] arry = new int[Totbyte];
for (int count = 0; count < data.Length; count++)
{
arry[count] = decimal.GetBits((data[count])decVal);//THIS LINE DOES NOT WORK.
Console.WriteLine("Byte to Decimal = {0},,,,,, count = {1}", arry[count], count);
}
}
}
}

Answers (1)