Hi i would like to know if it is possible to convert any file input into a number such as a long or integer and back into the file. Im not asking for you to program this for me id just like to know how you would do this in theory.
The 2 theories i have tried so far are 1. To convert the file into a byte array then into a long this was unsuccessful. 2. To convert the file into a string then into a long/integer this was also unsuccessful. The reason im posting is i would like your input into how you would go about doing this or if it is even possible. I understand that the number generated from this file would be huge so also realise that some larger file may need to be split into smaller files to do this.
I am only asking for your theories here on how to do this but code snipets are always welcome.
Thank you in advanced
Try one or more of those theories yourself and then when you are not successful come back with a specific question and we will help.
I have been trying different theories and still am unsuccessful. I do however have a more specific question.
Is it possible to convert a Base64String to a number (int/long) i have tried using ToInt64 with no success. here is my current code.
If not is there a different way to convert the file to a number with no data loss when converting the number back to a file.
static void Main(string args)
string file1 = @"C:\temp\1.txt";
fs1 = new System.IO.FileStream(file1, System.IO.FileMode.Open, System.IO.FileAccess.Read);
b1 = new Byte[fs1.Length];
long bytesRead = fs1.Read(b1, 0, (int)fs1.Length);
b64string = System.Convert.ToBase64String(b1,0,b1.Length);
long l1 = System.Convert.ToInt64(b64string);
catch (System.Exception exp)
What does your input file look like? Is it a text file that you're trying to read in and convert to an integer type? Can you post the contents of the input file (unless it's binary of course)?
For the input file i would like to be able to use any file type. This is why i was converting the file to a Base64String first.