c# - File upload app is stuck -


if run program , struploadip doens't exits in network whole application stuck

  fileinfo toupload = new fileinfo(strfile);                     ftpwebrequest req = (ftpwebrequest)webrequest.create(@"ftp://" + **struploadip** + @"/" + struser);                     req.method = webrequestmethods.ftp.makedirectory;                     req.credentials = new networkcredential(struusername, strupassword);                     try                     {                         using (var resp = (ftpwebresponse)req.getresponse())                         {                             console.writeline(resp.statuscode);                         }                     } 

how can try catch or something?

you should add try/catch handle errors.

    ftpwebrequest req = (ftpwebrequest)webrequest.create(@"ftp://" + **struploadip** + @"/" + struser);     req.method = webrequestmethods.ftp.makedirectory;     req.credentials = new networkcredential(struusername, strupassword);     try {         using (var resp = (ftpwebresponse)req.getresponse()) {             console.writeline(resp.statuscode);         }     } catch {         // todo: handle exception     } 

Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

php - Satis Composer Repository Installation -