Camillia
asked on
Duplicate this code using a different method
I've been Googling for half a day and I still don't know how to do this...
This works but I save the file in the database and I need to read it back from database into stream.
1. I use RadUpload to read the file content and save the file in database and encrypt it.
2. Now, I need to read the file back. I can do that but I also need to duplicate this row because I don't have RadUpload control when I read it back..
This is how I read the file back from the database. I can even display the file using Response but I don't want to display it. I want to read the content into a stream
//**** now how I read the content into a stream just like that line of code? Do I need to use Response.OutputStream OR StreamReader?
This works but I save the file in the database and I need to read it back from database into stream.
1. I use RadUpload to read the file content and save the file in database and encrypt it.
if (RadUpload1.UploadedFiles.Count > 0)
{
foreach (UploadedFile file in RadUpload1.UploadedFiles)
{
byte[] bytes = new byte[file.ContentLength];
file.InputStream.Read(bytes, 0, file.ContentLength);
...
//save in databse
2. Now, I need to read the file back. I can do that but I also need to duplicate this row because I don't have RadUpload control when I read it back..
file.InputStream.Read(bytes, 0, file.ContentLength);
This is how I read the file back from the database. I can even display the file using Response but I don't want to display it. I want to read the content into a stream
Byte[] bytesFile = null;
string fileExt = string.Empty;
string fileName = string.Empty;
using (SqlDataReader sdr = objSqlCmd.ExecuteReader())
{
while (sdr.Read())
{
bytesFile = (Byte[]) sdr[2];
fileExt = sdr[1].ToString();
fileName = sdr[0].ToString();
}
}
var decryptFile = bytesFile;
var decrypted = EncryptDecrypt.EncryptData(decryptFile, key, key, false); //I decrypt the file
//**** now how I read the content into a stream just like that line of code? Do I need to use Response.OutputStream OR StreamReader?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER