Foundation Expression
Blend 4 with Silverlight
By Victor Gaudioso
http://friendsofed.com/book.html?isbn=143022973X
http://www.amazon.com/Foundation-Expression-Blend-4-Silverlight/dp/143022973X
Tuesday, February 22, 2011
Book : Expression Blend 4 with Silverlight
Labels:
BOOK,
Expression Blend,
Silverlight 4
Book : ASP.NET MVC Framework Unleashed
ASP.NET MVC Framework Unleashed By Stephen Walther
http://www.informit.com/store/product.aspx?isbn=0672329980
http://stephenwalther.com/blog/category/11.aspx
http://www.informit.com/store/product.aspx?isbn=0672329980
http://stephenwalther.com/blog/category/11.aspx
Wednesday, February 9, 2011
What happens when user click .NET assembly (EXE)?
When you double click on a .net .exe assembly
Windows' PE (Portable Executable) loader kicks in 
If you're on a Windows >= Windows XP it will detect that the executable is a managed executable and will forward it to .net by calling _CoreExeMain in mscoree.dll (_CoreDllMain if you double clicked on a managed .dll). It can use the assembly configuration file to know which runtime to use. 
If you're on Windows < Windows XP, the .exe file contains a small native piece of code that will jump to mscoree.dll's _CoreExeMain or _CoreDllMain. 
Then mscoree.dll initializes the .net runtime, depending on the global configuration, the assembly configuration file, and what not. 
Then if it's a .exe, it will JIT compile its entry point method, and start executing it. 
Reference :
http://stackoverflow.com/questions/2788270/what-happens-when-user-click-net-assembly-exe
http://maneshjoseph.blogspot.com/2010/10/what-happens-when-you-click-on-net-exe.html
Reference :
http://stackoverflow.com/questions/2788270/what-happens-when-user-click-net-assembly-exe
http://maneshjoseph.blogspot.com/2010/10/what-happens-when-you-click-on-net-exe.html
Labels:
C#.Net
Saturday, February 5, 2011
Get the Image from a Image URL using C#.Net
Following is code to Get the Image from a Image URL using C#.Net
private Image ImageFromURL(string Url)
        {
            byte[] imageData = DownloadData(Url);
            ImageDetail imgDetail = new ImageDetail();
            Image img = null;
            try
            {
                MemoryStream stream = new MemoryStream(imageData);
                img = Image.FromStream(stream);
                
               
                stream.Close();
            }
            catch (Exception)
            {
            }
            return img;
        }
private byte[] DownloadData(string Url)
        {
            string empty = string.Empty;
            return DownloadData(Url, out empty);
        }
        private byte[] DownloadData(string Url, out string responseUrl)
        {
            byte[] downloadedData = new byte[0];
            try
            {
                //Get a data stream from the url
                WebRequest req = WebRequest.Create(Url);
                WebResponse response = req.GetResponse();
                Stream stream = response.GetResponseStream();
                responseUrl = response.ResponseUri.ToString();
                //Download in chuncks
                byte[] buffer = new byte[1024];
                //Get Total Size
                int dataLength = (int)response.ContentLength;
                //Download to memory
                //Note: adjust the streams here to download directly to the hard drive
                MemoryStream memStream = new MemoryStream();
                while (true)
                {
                    //Try to read the data
                    int bytesRead = stream.Read(buffer, 0, buffer.Length);
                    if (bytesRead == 0)
                    {
                        break;
                    }
                    else
                    {
                        //Write the downloaded data
                        memStream.Write(buffer, 0, bytesRead);
                    }
                }
                //Convert the downloaded stream to a byte array
                downloadedData = memStream.ToArray();
                //Clean up
                stream.Close();
                memStream.Close();
            }
            catch (Exception)
            {
                responseUrl = string.Empty;
                return new byte[0];
            }
            return downloadedData;
        }
Labels:
C#.Net
Save Image to Disk using C#.Net
After lot of search I found the code that saves Image class to harddisk. 
public void SaveImage(Image imgToSave, string FileName)
        {
            //Create empty bitmap image of original size
            Bitmap tempBmp = new Bitmap(imgToSave.Width, imgToSave.Height);
            Graphics g = Graphics.FromImage(tempBmp);
            //draw the original image on tempBmp
            g.DrawImage(imgToSave, 0, 0, imgToSave.Width, imgToSave.Height);
            //dispose originalImage and Graphics so the file is now free
            g.Dispose();
            imgToSave.Dispose();
            //Save the image file to original location
            tempBmp.Save(FileName, System.Drawing.Imaging.ImageFormat.Jpeg);
            
        }
Labels:
C#.Net
Friday, February 4, 2011
Code For Fetch Images from a URL using C#.net
public ListFetchImages(string Url) { List imageList = new List (); //Append http:// if necessary if (!Url.StartsWith("http://") && !Url.StartsWith("https://")) Url = "http://" + Url; string responseUrl = string.Empty; string htmlData = ASCIIEncoding.ASCII.GetString(DownloadData(Url, out responseUrl)); if (responseUrl != string.Empty) Url = responseUrl; if (htmlData != string.Empty) { string imageHtmlCode = " '); //make sure data will be inside img tag int start = htmlData.IndexOf(imageSrcCode) + imageSrcCode.Length; int end = htmlData.IndexOf('"', start + 1); //Extract the line if (end > start && start < brackedEnd) { string loc = htmlData.Substring(start, end - start); //Store line imageList.Add(loc); } //Move index to next image location if (imageHtmlCode.Length < htmlData.Length) index = htmlData.IndexOf(imageHtmlCode, imageHtmlCode.Length); else index = -1; } //Format the image URLs for (int i = 0; i < imageList.Count; i++) { string img = imageList[i]; string baseUrl = GetBaseURL(Url); if ((!img.StartsWith("http://") && !img.StartsWith("https://")) && baseUrl != string.Empty) img = baseUrl + "/" + img.TrimStart('/'); imageList[i] = img; } } return imageList; } private byte[] DownloadData(string Url) { string empty = string.Empty; return DownloadData(Url, out empty); } private byte[] DownloadData(string Url, out string responseUrl) { byte[] downloadedData = new byte[0]; try { //Get a data stream from the url WebRequest req = WebRequest.Create(Url); WebResponse response = req.GetResponse(); Stream stream = response.GetResponseStream(); responseUrl = response.ResponseUri.ToString(); //Download in chuncks byte[] buffer = new byte[1024]; //Get Total Size int dataLength = (int)response.ContentLength; //Download to memory //Note: adjust the streams here to download directly to the hard drive MemoryStream memStream = new MemoryStream(); while (true) { //Try to read the data int bytesRead = stream.Read(buffer, 0, buffer.Length); if (bytesRead == 0) { break; } else { //Write the downloaded data memStream.Write(buffer, 0, bytesRead); } } //Convert the downloaded stream to a byte array downloadedData = memStream.ToArray(); //Clean up stream.Close(); memStream.Close(); } catch (Exception) { responseUrl = string.Empty; return new byte[0]; } return downloadedData; }
Labels:
C#.Net
Code for Image to Byte Array and Byte Array to Image Converter using C#
Convert Image to byte[] array
public byte[] imageToByteArray(System.Drawing.Image imageIn)
{
MemoryStream ms = new MemoryStream();
imageIn.Save(ms,System.Drawing.Imaging.ImageFormat.Gif);
return  ms.ToArray();
}
Convert byte[] array to Imagepublic Image byteArrayToImage(byte[] byteArrayIn)
{
MemoryStream ms = new MemoryStream(byteArrayIn);
Image returnImage = Image.FromStream(ms);
return returnImage;
}
Labels:
C#.Net
Get File Name from URL (C#/.NET)
string FileName = URL.Substring(URL.LastIndexOf("/") + 1,
(URL.Length - URL.LastIndexOf("/") - 1));
Or:
string fileName = Path.GetFileName(url);
Ref:
http://www.thejackol.com/2007/04/10/get-file-name-from-url-cnet/
(URL.Length - URL.LastIndexOf("/") - 1));
Or:
string fileName = Path.GetFileName(url);
Ref:
http://www.thejackol.com/2007/04/10/get-file-name-from-url-cnet/
Labels:
C#.Net
Subscribe to:
Comments (Atom)
 
