This blog is about the dotnet.all types of codes,news about dotnet including asp.net,vb.net,c# and know about new dotnet technology.programing in asp.net,vb.net,c#, ajax, AJAX tech support for .net and discuss the new technology in dotnet.ncluding asp.net,vb.net,c# and know about new dotnet technology.programing in asp.net,vb.net,c#, ajax, AJAX tech support for .net and discuss the new technology in dotnet.asp.net programming,dot net programming,dotnet programs,dotnet source code,source code.

Free Hosting

Free Hosting

Showing posts with label file to bytes asp.net code. Show all posts
Showing posts with label file to bytes asp.net code. Show all posts

Sunday, November 2, 2008

Code To convert a file To bytes

This Function converts a file To bytes And returns it

CODE:
public static byte[] GetByteFromPostedFile(System.Web.HttpPostedFile PostedFileToUpload)
{
if ((PostedFileToUpload != null))
{
// Instantiate new byte for referencing in Add/Update method
byte[] byteFile = null;

try
{
//// Get reference to newly posted file
//postedFile = uploadedFile.PostedFile;
// Get size of Uploaded file
int intContentLength = PostedFileToUpload.ContentLength;
// Allocate a buffer for reading of the file
byteFile = new byte[intContentLength];
// Read uploaded file from the Stream
PostedFileToUpload.InputStream.Read(byteFile, 0, intContentLength);

return byteFile;
}
catch
{
return null;
}
}
else
{
return null;
}
}

dotnet(.Net) Project Source code Downloads and Tutorials

Email Subscrption



Enter your email address:

Delivered by FeedBurner

Feedburner Count

Unique Visitor

Design by araba-cı | MoneyGenerator Blogger Template by GosuBlogger