Click here to Skip to main content
15,902,777 members
Home / Discussions / C#
   

C#

 
GeneralRe: Windows Serice - Run Winform Application Pin
challouf19-Apr-09 13:31
challouf19-Apr-09 13:31 
QuestionSearch available socket servers Pin
Xmen Real 19-Apr-09 7:10
professional Xmen Real 19-Apr-09 7:10 
AnswerRe: Search available socket servers Pin
Natza Mitzi19-Apr-09 10:17
Natza Mitzi19-Apr-09 10:17 
GeneralRe: Search available socket servers Pin
Xmen Real 19-Apr-09 14:29
professional Xmen Real 19-Apr-09 14:29 
GeneralRe: Search available socket servers Pin
Naruki19-Apr-09 15:11
Naruki19-Apr-09 15:11 
GeneralRe: Search available socket servers Pin
Xmen Real 19-Apr-09 15:18
professional Xmen Real 19-Apr-09 15:18 
GeneralRe: Search available socket servers Pin
Naruki19-Apr-09 15:37
Naruki19-Apr-09 15:37 
QuestionSqlDataReader (SequentialAccess) solved.... but... Pin
Jacob Dixon19-Apr-09 6:33
Jacob Dixon19-Apr-09 6:33 
Ok, if you are reading this you may have seen the issue I was having with trying to us SqlDataReader(SequentialAccess) to read bytes from the VARBINARY(MAX) column. The problem was it wouldn't work with the VARBINARY column.

I have solved it using the IDataReader:

IDataReader myReader = cmd.ExecuteReader(CommandBehavior.SequentialAccess);

if (myReader != null)
{
    myReader.Read();

    long size = myReader.GetBytes(0, 0, null, 0, 0);
    byte[] buffer = new byte[size];

    int bufferSize = 255;
    int dataIndex = 0;
    long bytesRead = 0;
    SetProgBar(Convert.ToInt32(size));

    while ((bytesRead < size) && ((size - bytesRead) > 255))
    {
        if (bwLoadPicture.CancellationPending)
        {
            e.Cancel = true;
            SetLabelDownload("Picture download cancelled.");
        }
        else
        {
            bytesRead += myReader.GetBytes(0, dataIndex, buffer, dataIndex, bufferSize);
            dataIndex += 255;

            bwLoadPicture.ReportProgress(255);
            decimal FileSize = (Convert.ToDecimal(size) / 1024) / 1024;
            decimal CurrentSize = (Convert.ToDecimal(bytesRead) / 1024) / 1024;

            SetLabelDownload(String.Format("Downloading.. {0}MB of {1}MB", Math.Round(CurrentSize, 2).ToString(), Math.Round(FileSize, 2).ToString()));
        }
    }

    bytesRead += myReader.GetBytes(0, dataIndex, buffer, dataIndex, Convert.ToInt32((size - bytesRead)));
    SetLabelDownload("Finished Downloading.");

    MemoryStream ms = new MemoryStream(buffer);
    pictureBoxPicture.Image = Image.FromStream(ms);
    ms.Close();
}
myReader.Close();



Now my new question is...

Is there a way to do something like this when uploading a file/picture to a database? If you are uploading a large file I would like to display a progress bar. So some how I would have to get the total bytes of the file, then write 255 bytes at a time or so. Is this possible?
AnswerRe: SqlDataReader (SequentialAccess) solved.... but... Pin
N a v a n e e t h19-Apr-09 7:50
N a v a n e e t h19-Apr-09 7:50 
GeneralRe: SqlDataReader (SequentialAccess) solved.... but... Pin
Jacob Dixon19-Apr-09 9:20
Jacob Dixon19-Apr-09 9:20 
Questionhow can i prevent my application from being closed using task manager ? Pin
challouf19-Apr-09 2:57
challouf19-Apr-09 2:57 
AnswerRe: how can i prevent my application from being closed using task manager ? Pin
Vikram A Punathambekar19-Apr-09 4:37
Vikram A Punathambekar19-Apr-09 4:37 
GeneralRe: how can i prevent my application from being closed using task manager ? Pin
challouf19-Apr-09 4:56
challouf19-Apr-09 4:56 
GeneralRe: how can i prevent my application from being closed using task manager ? Pin
Jacob Dixon19-Apr-09 6:20
Jacob Dixon19-Apr-09 6:20 
AnswerRe: how can i prevent my application from being closed using task manager ? Pin
Xmen Real 19-Apr-09 6:24
professional Xmen Real 19-Apr-09 6:24 
GeneralRe: how can i prevent my application from being closed using task manager ? Pin
challouf19-Apr-09 7:22
challouf19-Apr-09 7:22 
AnswerRe: how can i prevent my application from being closed using task manager ? Pin
mmfatemi2-Jul-10 20:48
mmfatemi2-Jul-10 20:48 
Questionhow to extract attachments from PST and OST files Pin
Ramin Rahimee19-Apr-09 2:34
Ramin Rahimee19-Apr-09 2:34 
AnswerRe: how to extract attachments from PST and OST files Pin
_Maxxx_19-Apr-09 16:50
professional_Maxxx_19-Apr-09 16:50 
GeneralRe: how to extract attachments from PST and OST files Pin
Ramin Rahimee19-Apr-09 18:16
Ramin Rahimee19-Apr-09 18:16 
QuestionOptimizing File Copy Time Pin
#realJSOP19-Apr-09 1:47
professional#realJSOP19-Apr-09 1:47 
AnswerRe: Optimizing File Copy Time Pin
Mycroft Holmes19-Apr-09 1:57
professionalMycroft Holmes19-Apr-09 1:57 
AnswerRe: Optimizing File Copy Time Pin
S. Senthil Kumar19-Apr-09 2:00
S. Senthil Kumar19-Apr-09 2:00 
AnswerRe: Optimizing File Copy Time Pin
Luc Pattyn19-Apr-09 2:30
sitebuilderLuc Pattyn19-Apr-09 2:30 
GeneralRe: Optimizing File Copy Time Pin
harold aptroot19-Apr-09 2:58
harold aptroot19-Apr-09 2:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.