CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 12 of 12
  1. #1
    Join Date
    Dec 2012
    Posts
    20

    load/encrypt large files error memory out of exception

    it works with small files.but when I try to do with large files it gives system out of memory excetion.Please sir help me.I want change that coding using streamreader with a loop to store memory in chunks of bytes
    blow is short code.
    i want change the list line and want use stream reader for that to read if possible i want use a while loop
    public byte[] Secure(byte[] Data){
    //my encrypt function ....
    }
    .....
    string F = null;
    ...

    ...
    byte[] file1 = Secure(File.ReadAllBytes(textBox1.Text));
    Last edited by yousufshah; November 22nd, 2013 at 09:47 AM.

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: load/encrypt large files error memory out of exception

    You'll have to compute the size of the file, and then create a pointer for where you are, and a pointer from the starting place (0). Then keeping track of the two, compute a block size to use that won't eat up all the memory. 1024 byte increments might work best
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Dec 2012
    Posts
    20

    Re: load/encrypt large files error memory out of exception

    thank you mister dglienna.Thanks for response.I know that your solution will 100% work.but please help me in code.
    I want recode that line as you tells
    byte[] file1 = Secure(File.ReadAllBytes(textBox1.Text));.
    and secure function only accetpes
    public byte[] Secure(byte[] Data){
    //my encrypt function ....
    }.
    so please help me more

  4. #4
    Join Date
    Oct 2013
    Posts
    16

    Re: load/encrypt large files error memory out of exception

    Quote Originally Posted by yousufshah View Post
    thank you mister dglienna.Thanks for response.I know that your solution will 100% work.but please help me in code.
    I want recode that line as you tells
    byte[] file1 = Secure(File.ReadAllBytes(textBox1.Text));.
    and secure function only accetpes
    public byte[] Secure(byte[] Data){
    //my encrypt function ....
    }.
    so please help me more
    Convert the secure function to encrypt a list of byte[] instead of only one array and i can help you in code

    (ps: the max value of a byte array is the Int32.MaxValue)

  5. #5
    Join Date
    Dec 2012
    Posts
    20

    Re: load/encrypt large files error memory out of exception

    Quote Originally Posted by Reroto View Post
    Convert the secure function to encrypt a list of byte[] instead of only one array and i can help you in code

    (ps: the max value of a byte array is the Int32.MaxValue)
    thanks for hope.May I send you Full code in pm or here? i want fix that code.
    thank you reroto

  6. #6
    Join Date
    Oct 2013
    Posts
    16

    Re: load/encrypt large files error memory out of exception

    Quote Originally Posted by yousufshah View Post
    thanks for hope.May I send you Full code in pm or here? i want fix that code.
    thank you reroto
    Ok send or post it i'll try to help you

  7. #7
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: load/encrypt large files error memory out of exception

    textbox1.text sounds more like the problem.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  8. #8
    Join Date
    Dec 2012
    Posts
    20

    Re: load/encrypt large files error memory out of exception

    still no issue solved.please help me code.

  9. #9
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: load/encrypt large files error memory out of exception

    Inspect textbox1.text for it's value. Text is not binary data
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  10. #10
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: load/encrypt large files error memory out of exception

    Quote Originally Posted by yousufshah View Post
    thanks for hope.May I send you Full code in pm or here? i want fix that code.
    thank you reroto
    Quote Originally Posted by Reroto View Post
    Ok send or post it i'll try to help you
    Thanks for posting guys, and trying to help.
    Just remember that posting code through PM / emails do not benefit this forum and the possible members with the same problems.

    All code ( be it helpful or for purposes to understand the situation better ) must be posted in this thread, using Code tags.

    Hannes

  11. #11
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: load/encrypt large files error memory out of exception

    Quote Originally Posted by dglienna View Post
    textbox1.text sounds more like the problem.
    Why?
    Quote Originally Posted by dglienna View Post
    Inspect textbox1.text for it's value. Text is not binary data
    He is using ReadAllBytes to read all the bytes. As I understand, the TextBox ( textBox1 - which is not properly named ) is solely used to show the location of a file.

  12. #12
    Join Date
    Dec 2012
    Posts
    20

    Re: load/encrypt large files error memory out of exception

    textbox.text is the location of first file.I just want use binary reader wid loop to read 4 Bytesper round utill read all Bytes

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured