Convert binary64 into "avi"

N

nacho

Hello, I'm developing an application using C# as main language,
InfoPath as Input for a XML file and a Web Service in c# to deal with
the XML file generated by InfoPath and then convert it into another
different and customized XML file which I will used from a web
application in C#

The problem:
In InfoPath I have a field as "file attachment", I click on it, attach
the a video in "avi" format and submit it to a Web Service. XML file is
generated and the video "avi" is converted well to binary64. Now I want
to convert this binary64 into avi again using C#

does anybody know how to deal with it??

thanks in adavance

nacho
 
J

Jon Skeet [C# MVP]

nacho said:
Hello, I'm developing an application using C# as main language,
InfoPath as Input for a XML file and a Web Service in c# to deal with
the XML file generated by InfoPath and then convert it into another
different and customized XML file which I will used from a web
application in C#

The problem:
In InfoPath I have a field as "file attachment", I click on it, attach
the a video in "avi" format and submit it to a Web Service. XML file is
generated and the video "avi" is converted well to binary64. Now I want
to convert this binary64 into avi again using C#

does anybody know how to deal with it??

Convert.FromBase64String will give you the data in binary format.
However, it's likely to be rather large - you might wish to consider
streaming it with a CryptoStream using a FromBase64Transform.
 
C

Curious

Hi,

I'm not sure if this is what you require. Take a look at it and maybe
give it a try.

private bool encoding_Base64(string filename, string file)
{
BinaryWriter binaryWriter;
FileStream fileStream;
string[] lines;

bool flag;

flag = true;
lines = file.Split(Environment.NewLine.ToCharArray());
try
{
fileStream = new FileStream(@filename, FileMode.CreateNew);
binaryWriter = new BinaryWriter(fileStream);
foreach(string line in lines)
binaryWriter.Write(Convert.FromBase64String(line));

binaryWriter.Close();
} // end try statement
catch
{
flag = false;
} // end catch statement

return flag;
}
 
N

nacho

Thanks a lot to you two, I'm going to try and tell you later the
results
cheers!

nacho
 
N

nacho

The script works well, thanks Curious, it converts well the binary64 to
avi.

The problem now is that InfoPath adds some text at the begining of the
"avi".
The Web Service renames and reallocates the "avi" file.
Lets say I have a file called "testOne.avi" which is the one to be
attached in the InfoPath form, then I click submit, the Web Service
takes "testOne.avi" in binary64 from the XML passed to it and generates
and reallocates the new "avi" file. Well, the new "avi" file already in
the hard drive is 1kb bigger than the original because the following
text was added by InfoPath on the header.

"ÇIFA   t e s t O n e . a v i "

this bit of text does not allow me to open it.

Well, just to let you know what happend and how InfoPath behaves with
me. There might be a way of getting rid of this.... I will try to find
out.

I'm going to try the CryptoStream now, I might require if my videos are
big. Cheers Jon.

Thanks again

Nacho
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top