locked
Convert compressed file to byte? RRS feed

  • Question

  • Hello everyone!

    I have a web form, that will upload a file (always .rar/.zip).
    Its possible to convert those formats to byte[] ?

    I'm asking that, because usually, on another systems, when my user upload a file, i convert it to byte[] and store that as blob on my oracle database, so i was wondering if i could do the same.

    Thankz, warm regardz!


    If you get your question answered, please come back and Alternate TextMark As Answer.
    Web Developer

    Monday, July 28, 2014 7:59 PM

Answers

  • When the file is sent to the server it'll come across as a byte[].  You don't need to convert anything.  For steps on how to get the file back from the client you should post in the ASP.NET forums (http://forums.asp.net ).

    Michael Taylor
    http://blogs.msmvps.com/p3net

    • Proposed as answer by Caillen Tuesday, July 29, 2014 7:51 AM
    • Marked as answer by Caillen Friday, August 8, 2014 9:33 AM
    Monday, July 28, 2014 8:45 PM
  • Yes, if you're having a Web Forms application then it would surely be using ASP.NET technology.

    Once you upload the media or file to the server, Form's enctype and other technologies would jump in and they'll convert the file to the byte[] array so that it is sent to the server with some encoding scheme. This way, even if you don't convert, it surely would get converted to byte[]. 

    If you've already done that job, then you surely would know that everything is stored as a byte or array of bytes. Its just us, who think this file is .rar and this is .jpg. 

    You can use the class FileStream for this purpose here, I think that'll be better.


    ~!Firewall!~


    Monday, July 28, 2014 10:14 PM

All replies

  • When the file is sent to the server it'll come across as a byte[].  You don't need to convert anything.  For steps on how to get the file back from the client you should post in the ASP.NET forums (http://forums.asp.net ).

    Michael Taylor
    http://blogs.msmvps.com/p3net

    • Proposed as answer by Caillen Tuesday, July 29, 2014 7:51 AM
    • Marked as answer by Caillen Friday, August 8, 2014 9:33 AM
    Monday, July 28, 2014 8:45 PM
  • Yes, if you're having a Web Forms application then it would surely be using ASP.NET technology.

    Once you upload the media or file to the server, Form's enctype and other technologies would jump in and they'll convert the file to the byte[] array so that it is sent to the server with some encoding scheme. This way, even if you don't convert, it surely would get converted to byte[]. 

    If you've already done that job, then you surely would know that everything is stored as a byte or array of bytes. Its just us, who think this file is .rar and this is .jpg. 

    You can use the class FileStream for this purpose here, I think that'll be better.


    ~!Firewall!~


    Monday, July 28, 2014 10:14 PM
  • Hello,

       Simple try this way,
    return File.ReadAllBytes(fileName);

    -----------------------------------------

     if the reply help you mark it as your answer.
     Free No OLE .NET PowerPoint, Word ExcelPDF  Component(Create, Modify, Convert & Print) 

    Tuesday, July 29, 2014 2:01 AM