I'm working with the AES Decryptor (using RijndaelManaged), but when I try to initialize a byte array to store my ciphertext data, it throws an IndexOutOfRange exception.
using (FileStream Ciphertext = new FileStream(_InputPath, FileMode.Open, FileAccess.Read, FileShare.None)) //For Plaintext Stream
using (FileStream PlainText = new FileStream(_OutputPath, FileMode.Create, FileAccess.Write, FileShare.None)) //For Ciphertext Stream
using (CryptoStream CStreamWriter = new CryptoStream(PlainText, Decryptor, CryptoStreamMode.Write)) //For CryptoStream Writer
byte CTextData = new byte[Ciphertext.Length]; //EXCEPTION THROWN HERE
The exact error message is: "Index was outside the bounds of the array."
The weird thing is, this only happens for file > 200MB. But for a 150mb file, I have no problem.
Please advice thanks!
It is said that the most complex structures built by mankind are software systems. This is not generally appreciated because most people cannot see them. Maybe that's a good thing because if we saw them as buildings, we'd deem many of them unsafe.
ihave a asp.net page having some textboxes and dropdownlists , and one checkbox ,
i want that when i check checkbox and click the sibmit button then this data of the page should be redirect to next page but with the checkbox to be transfered as checked and readonly. and also i have three textboxes whose values are taken froma datebox which i created from javasript. so i want this date value also to be transfered to the next page. the next page is of data updation so in the next page all this value will be send and when in that next page i can click update button and then i will get be redirect or get a update success message on the same or another page .
my 1st page name is first_page
2nd page name is secound_page
throws an 'A generic error occurred in GDI+' exception. The image file loaded in the OnBrowse handler is not the same image file I'm trying to save to. The target directory has read and write permissions. The output file is created when I run the program but has a length of zero bytes.
I've searched Google and all the solutions indicate a permissions error, which would make sense if the file isn't even created but, as it is created, I can't see it being a permission problem.
this is my standard advice on Image.Save problems:
Most, if not all, errors inside GDI+ are reported as "generic problem occurred in
GDI+". If the affected line is an Image.Save chances are your path is incorrect or
inaccessible, your disk is full, or your destination file exists and is locked.
if you load an image from a file, most of the time the file remains locked as long as
the Image is alive. This would prevent you from saving an image to the same path.
It applies to Image.FromFile, and probably also to PictureBox.ImageLocation
The one exception I am aware of is when you use Image.FromStream
An alternative work-around is to work with a copy of the image:
load the image with Image.FromFile,
create a new image from it with new Bitmap(Image),
dispose of the original image.
I need just a simple console program to tell how many days and hours (minutes if possible) until this persons next birthday.
He was born on July 26th 1983 at 8:00 pm.
I'm really new at this and I wanted to give him a small exe (console program) for his birthday.
This is all I oould come up with so far:
public static void Main()
DateTime CurrTime = DateTime.Now;
DateTime JimBDay = DateTime.Compare(CurrTime, "08/01/2008");
Console.WriteLine("Jim's Birthdate: ", JimBDay);
Console.WriteLine("Jim's Birthday is July 26th at 8:00 pm");
// Need some code to say there are this many days and this many hours until your next birthday (minutes if possible).
i have a client.exe and c# program. . my exe can open only with my program. my exe cannot open alone.when i click button1 on my program , client.exe will open. But when i double click to client.exe , client.exe cant open.
I have windows form where I am adding control at run time but I couldn't remove them all. Some of them get removed but some stays there. I have spent already 4 hours nothing making sense why I couldn't simply remove controls from the form.
this.Controls(btn);---> this is how iam adding Controls
foreach (Control c in this.Controls)---> this is how am removing-->no achievement
but if copy all the controls to an arraylist and then it works. What a nosense is this is C#
ArrayList a = new ArrayList();
foreach (Control c in this.Controls )
foreach (Control cc in a)
Every iteration of your foreach loop is incrementing an index,
but you're removing a control so all the other controls are shifted
up one in the collection. That means you'll miss every other control I
Maybe something like this:
for (int i = this.Controls.Count - 1; i >= 0; i--)
// maybe dispose the control at index i here
// remove the control at index i from the collection
Microsoft MVP - Visual C++
Last Visit: 12-Jul-20 20:28 Last Update: 12-Jul-20 20:28