Click here to Skip to main content
15,895,557 members
Home / Discussions / C#
   

C#

 
AnswerRe: What is the difference between JavaScript 'var' and C# 'dynamic' Pin
Richard MacCutchan12-Feb-14 21:41
mveRichard MacCutchan12-Feb-14 21:41 
AnswerRe: What is the difference between JavaScript 'var' and C# 'dynamic' Pin
BillWoodruff12-Feb-14 22:40
professionalBillWoodruff12-Feb-14 22:40 
Questiondatagridview combobox Pin
abdul rafi12-Feb-14 19:29
abdul rafi12-Feb-14 19:29 
AnswerRe: datagridview combobox Pin
Eddy Vluggen13-Feb-14 9:06
professionalEddy Vluggen13-Feb-14 9:06 
Question3D Model Pin
Kadam dIgambar12-Feb-14 18:07
Kadam dIgambar12-Feb-14 18:07 
SuggestionRe: 3D Model Pin
Richard MacCutchan12-Feb-14 21:39
mveRichard MacCutchan12-Feb-14 21:39 
GeneralRe: 3D Model Pin
JV999914-Feb-14 3:07
professionalJV999914-Feb-14 3:07 
QuestionConverting Back from Decimal to Byte Pin
computerpublic12-Feb-14 10:03
computerpublic12-Feb-14 10:03 
/*
First Phase:: I attempting to copy a file off my desktop into a byte array. Then transposing all the bytes into an equivalent decimal array. The decimal array is must (it is very important).

Second Phase:: I am attempting to convert the same decimal array back to a byte array and write the file back to the desktop or a folder or path. 

The first phase was accomplish with help from the forum, but the second gives me back a garbage file on the desktop. I was attempting to use WriteAllBytes, but I do not know how to use this method. Can you someone please assist me with "WriteAllBytes" or show simply show me how to stop getting garbage file?
*/
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;
            }
            Console.WriteLine("Total Bytes = {0} bytes", Totbyte);
            string temPath = Path.GetTempFileName();
            byte[] data = new byte[Totbyte];
 
            if (File.Exists(temPath))
            {
                data = File.ReadAllBytes(filePath);
                File.WriteAllBytes(temPath, data);
            }
            decimal[] arry = new decimal[Totbyte];
            for (int count = 0; count < data.Length; count++)
            {
                arry[count] = data[count];
             //   Console.WriteLine("Byte to Decimal = {0},,,,,, count = {1}", arry[count], count);
            }
            ///////////ABOVE: READ IN FILE AND CHANGE EACH BYTE TO DECIMAL
            ///////////BELOW: TRYING TO REVERSE THE ABOVE PROCESS
            byte[] data2 = new byte[Totbyte];
            for (int count = 0; count < arry.Length; count++)
            {
                data2[count] = (byte)arry[count];
            }
            FileStream file = new FileStream(filePath, FileMode.Create);
            BinaryWriter binarystream = new BinaryWriter(file);
            binarystream.Write(data2);
            binarystream.Close();
        }
    }
}

AnswerRe: Converting Back from Decimal to Byte Pin
Richard Deeming12-Feb-14 11:07
mveRichard Deeming12-Feb-14 11:07 
GeneralRe: Converting Back from Decimal to Byte Pin
computerpublic12-Feb-14 11:29
computerpublic12-Feb-14 11:29 
GeneralRe: Converting Back from Decimal to Byte Pin
Richard Deeming13-Feb-14 0:37
mveRichard Deeming13-Feb-14 0:37 
GeneralRe: Converting Back from Decimal to Byte Pin
computerpublic13-Feb-14 9:15
computerpublic13-Feb-14 9:15 
GeneralRe: Converting Back from Decimal to Byte Pin
Richard Deeming13-Feb-14 10:35
mveRichard Deeming13-Feb-14 10:35 
GeneralRe: Converting Back from Decimal to Byte Pin
computerpublic13-Feb-14 10:48
computerpublic13-Feb-14 10:48 
GeneralRe: Converting Back from Decimal to Byte Pin
computerpublic16-Feb-14 6:00
computerpublic16-Feb-14 6:00 
GeneralRe: Converting Back from Decimal to Byte Pin
computerpublic16-Feb-14 6:03
computerpublic16-Feb-14 6:03 
GeneralRe: Converting Back from Decimal to Byte Pin
Richard Deeming17-Feb-14 1:46
mveRichard Deeming17-Feb-14 1:46 
GeneralRe: Converting Back from Decimal to Byte Pin
computerpublic18-Feb-14 22:51
computerpublic18-Feb-14 22:51 
GeneralRe: Converting Back from Decimal to Byte Pin
computerpublic18-Feb-14 23:03
computerpublic18-Feb-14 23:03 
GeneralRe: Converting Back from Decimal to Byte Pin
Richard Deeming19-Feb-14 1:59
mveRichard Deeming19-Feb-14 1:59 
GeneralRe: Converting Back from Bit to Byte Pin
computerpublic13-Mar-14 8:16
computerpublic13-Mar-14 8:16 
AnswerRe: Converting Back from Decimal to Byte Pin
Eddy Vluggen12-Feb-14 11:21
professionalEddy Vluggen12-Feb-14 11:21 
QuestionRe: Converting Back from Decimal to Byte Pin
Richard MacCutchan12-Feb-14 21:38
mveRichard MacCutchan12-Feb-14 21:38 
Questiontreeview and database Pin
danmor49812-Feb-14 6:45
danmor49812-Feb-14 6:45 
QuestionRe: treeview and database Pin
Ravi Bhavnani12-Feb-14 7:28
professionalRavi Bhavnani12-Feb-14 7:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.