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
Post a Comment