Click here to Skip to main content
15,905,508 members
Home / Discussions / C#
   

C#

 
AnswerRe: Article "tip/trick "Converting Enum member names and values in C#"" Pin
PIEBALDconsult17-Feb-21 3:17
mvePIEBALDconsult17-Feb-21 3:17 
GeneralRe: Article "tip/trick "Converting Enum member names and values in C#"" Pin
Сергій Ярошко17-Feb-21 4:13
professionalСергій Ярошко17-Feb-21 4:13 
GeneralRe: Article "tip/trick "Converting Enum member names and values in C#"" Pin
Richard Deeming17-Feb-21 4:31
mveRichard Deeming17-Feb-21 4:31 
GeneralRe: Article "tip/trick "Converting Enum member names and values in C#"" Pin
PIEBALDconsult17-Feb-21 5:19
mvePIEBALDconsult17-Feb-21 5:19 
QuestionHow C# handles binary files? Pin
Member 1477325816-Feb-21 21:59
Member 1477325816-Feb-21 21:59 
AnswerRe: How C# handles binary files? Pin
Richard MacCutchan16-Feb-21 22:11
mveRichard MacCutchan16-Feb-21 22:11 
AnswerRe: How C# handles binary files? Pin
OriginalGriff16-Feb-21 22:39
mveOriginalGriff16-Feb-21 22:39 
AnswerRe: How C# handles binary files? Pin
Gerry Schmitz17-Feb-21 6:00
mveGerry Schmitz17-Feb-21 6:00 
QuestionC#, loop statement Pin
Jennalyn Nayoyos15-Feb-21 2:57
Jennalyn Nayoyos15-Feb-21 2:57 
AnswerRe: C#, loop statement Pin
OriginalGriff15-Feb-21 3:16
mveOriginalGriff15-Feb-21 3:16 
AnswerRe: C#, loop statement Pin
Richard MacCutchan15-Feb-21 4:53
mveRichard MacCutchan15-Feb-21 4:53 
AnswerRe: C#, loop statement Pin
Gerry Schmitz15-Feb-21 6:10
mveGerry Schmitz15-Feb-21 6:10 
QuestionRe: C#, loop statement Pin
Kenneth Haugland15-Feb-21 19:42
mvaKenneth Haugland15-Feb-21 19:42 
AnswerRe: C#, loop statement Pin
Richard MacCutchan15-Feb-21 21:13
mveRichard MacCutchan15-Feb-21 21:13 
QuestionWITSML Server And Client in C# Pin
Member 1332584614-Feb-21 21:59
Member 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
Member 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
Member 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 

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.