public static byte[] takeScreenShot()
{
// Set the bitmap object to the size of the screen
bmpScreenShot
= new Bitmap
(Screen
.PrimaryScreen.Bounds.Width, Screen
.PrimaryScreen.Bounds.Height, PixelFormat
.Format32bppArgb); // Create a graphics object from the bitmap
gfxScreenShot = Graphics.FromImage(bmpScreenShot);
// Take the screenshot from the upper left corner to the right bottom corner
gfxScreenShot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);
// Save the screenshot to the specified path that the user has chosen
bmpScreenShot.Save("Imagen" + index.ToString(), System.Drawing.Imaging.ImageFormat.Png);
byte[] size = getFileSize("Imagen" + index.ToString() + ".png") ;
byte[] name = System.Text.ASCIIEncoding.ASCII.GetBytes("|Imagen" + index.ToString() + ".png");
index++;
bmpScreenShot.Dispose();
gfxScreenShot.Dispose();
return joinByteArray(size, name);
}