Click here to Skip to main content
14,869,740 members
Home / Discussions / C#
   

C#

 
QuestionWITSML Server And Client in C# Pin
Member 1332584614-Feb-21 21:59
MemberMember 1332584614-Feb-21 21:59 
AnswerRe: WITSML Server And Client in C# Pin
Richard MacCutchan14-Feb-21 22:18
mveRichard MacCutchan14-Feb-21 22:18 
GeneralRe: WITSML Server And Client in C# Pin
Member 1332584614-Feb-21 22:51
MemberMember 1332584614-Feb-21 22:51 
Question[solved] Two-way binding winforms checkbox to property? Pin
RobertSF14-Feb-21 6:21
professionalRobertSF14-Feb-21 6:21 
AnswerRe: Two-way binding winforms checkbox to property? Pin
Gerry Schmitz14-Feb-21 6:37
mveGerry Schmitz14-Feb-21 6:37 
GeneralRe: Two-way binding winforms checkbox to property? Pin
RobertSF14-Feb-21 7:42
professionalRobertSF14-Feb-21 7:42 
GeneralRe: Two-way binding winforms checkbox to property? Pin
Gerry Schmitz14-Feb-21 8:20
mveGerry Schmitz14-Feb-21 8:20 
QuestionNeed code to download file from FTP with Auto Resume functionality in case of Internet disconnection. Pin
Member 1507143012-Feb-21 6:00
MemberMember 1507143012-Feb-21 6:00 
I am using following code to download file from FTP. I want to enhance this code with Auto Resume functionality in case of Internet disconnection. This code works perfect to download a file but doesn't auto resume. Please provide me C# source code to apply auto resume. My code supports bigger file also that is multiple GB download. Please review my code and please suggest how in my code I can integrate Resume.

\\\\\\\\\\\\\\\\\\\\ code 
try
    {

        //Create FTP Request.
        FtpWebRequest request = (FtpWebRequest)WebRequest.Create(FTPPath);
        request.Method = WebRequestMethods.Ftp.DownloadFile;

        //Enter FTP Server credentials.
        request.Credentials = new NetworkCredential(FTPUser, FTPPassword);
        request.UsePassive = true;
        request.UseBinary = true;
        request.EnableSsl = false;

        FtpWebResponse response = (FtpWebResponse)request.GetResponse();
        using (Stream stream = response.GetResponseStream())
        {
            int length = 0;
            int bytesToRead = 26214400;
            byte[] buffer = new Byte[bytesToRead]; // Buffer to read bytes in chunk size specified above

            long responseFileLength = this.FtpGetFileSize(FTPPath, FTPUser, FTPPassword); // Get the file size on the ftp   

            HttpContext.Current.Response.Buffer = false;
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.ClearContent();
            HttpContext.Current.Response.ClearHeaders();
            HttpContext.Current.Response.Expires = -1;

            
            HttpContext.Current.Response.ContentType = "application/octet-stream";
            HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=\"" + origionalFileName + "\"");
            HttpContext.Current.Response.AddHeader("Content-Length", responseFileLength.ToString());

            
                do
                {
                    
                    if (HttpContext.Current.Response.IsClientConnected)
                    {
                        length = stream.Read(buffer, 0, bytesToRead);
                        HttpContext.Current.Response.OutputStream.Write(buffer, 0, length);
                        HttpContext.Current.Response.Flush();
                        buffer = new Byte[bytesToRead];
                    }
                    else
                    {
                        length = -1;
                    }
                } while (length > 0); //Repeat until no data is read
            
            IsDownloaded = true;
            HttpContext.Current.Response.Clear();
        }
            }
        catch (WebException ex)
        {
    
        }

AnswerRe: Need code to download file from FTP with Auto Resume functionality in case of Internet disconnection. Pin
Gerry Schmitz12-Feb-21 9:19
mveGerry Schmitz12-Feb-21 9:19 
AnswerRe: Need code to download file from FTP with Auto Resume functionality in case of Internet disconnection. Pin
Mycroft Holmes12-Feb-21 10:08
professionalMycroft Holmes12-Feb-21 10:08 
AnswerRe: Need code to download file from FTP with Auto Resume functionality in case of Internet disconnection. Pin
Luc Pattyn13-Feb-21 5:56
sitebuilderLuc Pattyn13-Feb-21 5:56 
QuestionDoes anyone know the C# implementation for this? Pin
kangkongflea12-Feb-21 0:38
Memberkangkongflea12-Feb-21 0:38 
SuggestionRe: Does anyone know the C# implementation for this? Pin
Richard MacCutchan12-Feb-21 1:15
mveRichard MacCutchan12-Feb-21 1:15 
AnswerRe: Does anyone know the C# implementation for this? Pin
OriginalGriff12-Feb-21 2:07
mveOriginalGriff12-Feb-21 2:07 
AnswerRe: Does anyone know the C# implementation for this? Pin
Luc Pattyn12-Feb-21 3:37
sitebuilderLuc Pattyn12-Feb-21 3:37 
AnswerRe: Does anyone know the C# implementation for this? Pin
Gerry Schmitz12-Feb-21 9:21
mveGerry Schmitz12-Feb-21 9:21 
QuestionHow to access GUI from another thread? Pin
Alex Dunlop11-Feb-21 7:10
MemberAlex Dunlop11-Feb-21 7:10 
AnswerRe: How to access GUI from another thread? Pin
Gerry Schmitz11-Feb-21 7:39
mveGerry Schmitz11-Feb-21 7:39 
GeneralRe: How to access GUI from another thread? Pin
Alex Dunlop11-Feb-21 7:40
MemberAlex Dunlop11-Feb-21 7:40 
GeneralRe: How to access GUI from another thread? Pin
Alex Dunlop11-Feb-21 8:07
MemberAlex Dunlop11-Feb-21 8:07 
GeneralRe: How to access GUI from another thread? Pin
Dave Kreskowiak11-Feb-21 13:17
mveDave Kreskowiak11-Feb-21 13:17 
AnswerRe: How to access GUI from another thread? Pin
Gerry Schmitz11-Feb-21 9:03
mveGerry Schmitz11-Feb-21 9:03 
AnswerRe: How to access GUI from another thread? Pin
Ralf Meier11-Feb-21 10:36
professionalRalf Meier11-Feb-21 10:36 
AnswerRe: How to access GUI from another thread? Pin
Luc Pattyn11-Feb-21 11:29
sitebuilderLuc Pattyn11-Feb-21 11:29 
GeneralRe: How to access GUI from another thread? Pin
Eddy Vluggen11-Feb-21 14:01
professionalEddy Vluggen11-Feb-21 14:01 

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.