当前位置: 首页>>代码示例>>C#>>正文


C# WebResponse.Close方法代码示例

本文整理汇总了C#中System.Net.WebResponse.Close方法的典型用法代码示例。如果您正苦于以下问题:C# WebResponse.Close方法的具体用法?C# WebResponse.Close怎么用?C# WebResponse.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Net.WebResponse的用法示例。


在下文中一共展示了WebResponse.Close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CheckURL

        public bool CheckURL(string url)
        {
            ourUri = new Uri(url);
            myWebRequest = WebRequest.Create(url);
            try
            {
                myWebResponse = myWebRequest.GetResponse();
            }
            catch
            {
                myWebResponse.Close();
                return false;

            }
            myWebResponse.Close();
            return true;
        }
开发者ID:Igorurievich,项目名称:Radioplayer,代码行数:17,代码来源:CheckWeb.cs

示例2: Read

 /// <include file='doc\TextReturnReader.uex' path='docs/doc[@for="TextReturnReader.Read"]/*' />
 public override object Read(WebResponse response, Stream responseStream) {
     try {
         string decodedString = RequestResponseUtils.ReadResponse(response);
         return matcher.Match(decodedString);
     }
     finally {
         response.Close();
     }
 }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:10,代码来源:TextReturnReader.cs

示例3: S3Response

		private S3Response(WebResponse response)
		{
			this.response = response;
			Stream responseStream = response.GetResponseStream();
			StreamReader streamReader = new StreamReader(responseStream);
			this.responseString = streamReader.ReadToEnd();
			streamReader.Close();
			responseStream.Close();
			response.Close();
		}
开发者ID:mikhp,项目名称:greatmaps,代码行数:10,代码来源:S3Response.cs

示例4: DownloadImage

 private void DownloadImage(WebResponse response, string url)
 {
     using (Stream stream = response.GetResponseStream())
     {
         var memoryStream = new MemoryStream();
         stream.CopyTo(memoryStream);
         var data = memoryStream.ToArray();
         AddImageCache(url, data);
     }
     response.Close();
 }
开发者ID:Chicken4WP8,项目名称:Chicken4WP,代码行数:11,代码来源:ImageCacheService.cs

示例5: ExecutionResult

 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="response">Response of type System.Net.WebResponse</param>
 internal ExecutionResult(System.Net.WebResponse response)
 {
     this.status = ((HttpWebResponse)response).StatusDescription;
     dataStream = response.GetResponseStream();
     StreamReader reader = new StreamReader(dataStream);
     responseFromServer = reader.ReadToEnd();
     reader.Close();
     dataStream.Close();
     this.response = response;
     response.Close();
 }
开发者ID:projectpvg1,项目名称:BE-Project,代码行数:15,代码来源:ExecutionResult.cs

示例6: GetdataByStates

 private void GetdataByStates(IAsyncResult result)
 {
     response = request.EndGetResponse(result);
     StreamReader sd = new StreamReader(response.GetResponseStream());
     JsonReader jreader = new JsonTextReader(sd);
     JsonSerializer se = new JsonSerializer();
     Dictionary<string, object> GetdataState = se.Deserialize<Dictionary<string, object>>(jreader);
     dataList = DataStatebyvotes(GetdataState);
     response.Close();
     sd.Close();
     global.my_flag = 1;
 }
开发者ID:jagan27101986,项目名称:WP7,代码行数:12,代码来源:GetDataByStatesJSONRequest.cs

示例7: CloseQuietly

 public static void CloseQuietly(WebResponse response)
 {
     try
     {
         if (response != null)
         {
             response.Close();
         }
     }
     catch (Exception ex)
     {
         log.Warn(response, ex);
     }
 }
开发者ID:killbug2004,项目名称:cosps,代码行数:14,代码来源:WebAgentAsync.cs

示例8: getLyrics

        public string[] getLyrics(String author, String songName)
        {

            string[] result = null;

            try
            {
                request = WebRequest.Create(createURL(author, songName));
                response = request.GetResponse();

                String lyrics = "";

                //now do crawling
                using (StreamReader reader = new StreamReader(response.GetResponseStream()))
                {
                    doc.LoadHtml(reader.ReadToEnd());

                    lyrics = doc.DocumentNode.SelectSingleNode(Assets.DIV_NAME).InnerText;

                    foreach (HtmlNode node in doc.DocumentNode.SelectSingleNode(Assets.DIV_LYRICS).ChildNodes)
                    {
                        lyrics += node.InnerText;
                        lyrics += "\n\n";
                    }
                }

                response.Close();

                String parts = "";

                HtmlNode partnode = doc.DocumentNode.SelectSingleNode(Assets.PLUS_INFO);
                foreach (HtmlNode node in partnode.Elements(Assets.P_TAG))
                {
                    parts += node.InnerText + "\n\n";
                }

                result = new string[4];
                result[0] = doc.DocumentNode.SelectSingleNode(Assets.IMAGE_XPATH).Attributes[Assets.SRC_ATTR].Value;
                result[1] = lyrics;
                result[2] = parts;
                result[3] = "\n\nSource:Metro Lyrics";

            }
            catch
            { 
            
            }

            return result;
        }
开发者ID:MilosSimic,项目名称:snakeRoot,代码行数:50,代码来源:WebCrawler.cs

示例9: Read

 public override object Read(WebResponse response, Stream responseStream)
 {
     object obj2;
     try
     {
         string text = RequestResponseUtils.ReadResponse(response);
         obj2 = this.matcher.Match(text);
     }
     finally
     {
         response.Close();
     }
     return obj2;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:14,代码来源:TextReturnReader.cs

示例10: ParseResponseStreamToText

 public static string ParseResponseStreamToText(WebResponse response)
 {
     try
     {
         StreamReader reader = new StreamReader(response.GetResponseStream());
         
         string robotsTxt = reader.ReadToEnd();
         
         response.Close();
         reader.Close();
         
         return robotsTxt;
     }
     catch (Exception ex)
     {
         throw new Exception("An error occurred while I try to read Response Stream :(", ex);
     }
 }
开发者ID:cassiodeveloper,项目名称:labs.cassiobp.com.br,代码行数:18,代码来源:Util.cs

示例11: Save

        public bool Save( string ImagePath, string ImageURL){

            if (! Directory.Exists(ImagePath))
                Directory.CreateDirectory(ImagePath);

            string ImageName = Path.GetFileName(ImageURL);

            // Read image as byte array
            try
            {
                RequestToImage = (HttpWebRequest) WebRequest.Create(ImageURL);
                ImageResponse = RequestToImage.GetResponse();
                ResponseStream = ImageResponse.GetResponseStream();
                BinaryReader = new BinaryReader(ResponseStream);

                Image = BinaryReader.ReadBytes(500000);
            }
            catch (IOException) { MessageBox.Show("Failed to load image."); }
            finally
            {
                BinaryReader.Close();
                ResponseStream.Close();
                ImageResponse.Close();
            }
            
            // Write image to file
            FileStream = new FileStream(ImagePath + ImageName, FileMode.Create);
            BinaryWriter = new BinaryWriter(FileStream);

            try
            {
                BinaryWriter.Write(Image);
            }
            catch (IOException) { MessageBox.Show("Failed to save image."); }
            finally
            {
                FileStream.Close();
                BinaryWriter.Close();
            }

            this.ImagePath = ImagePath + ImageName;

            return File.Exists(this.ImagePath);
        }
开发者ID:JozefCipa,项目名称:bing_wallpaper,代码行数:44,代码来源:ImageManager.cs

示例12: Start

        // Use this for initialization
        void Start()
        {
            //test first, need to use linq.
            request = HttpWebRequest.Create("http://io.adafruit.com/api/feeds.json");
            request.Headers.Add("X-AIO-Key", KeyManager.key);
            response = request.GetResponse();
            Debug.Log(response);
            Debug.Log(response.GetResponseStream());
            Stream data = response.GetResponseStream();
            StreamReader reader = new StreamReader(data);
            string responseFromServer = reader.ReadToEnd();
            reader.Close();
            data.Close();
            response.Close();
            Debug.Log(responseFromServer);

            ArrayList decoded = (ArrayList) JSON.JsonDecode(responseFromServer);
            Debug.Log(decoded.Count);
            Debug.Log(((Hashtable)decoded[0])["key"]);
            Feed f = new Feed((Hashtable)decoded[0]);
            Debug.Log(f.name);
        }
开发者ID:tapiralec,项目名称:adafruit-io-unity3D,代码行数:23,代码来源:http.cs

示例13: GetXpathDocumentFromResponse

        protected virtual XPathNavigator GetXpathDocumentFromResponse(WebResponse response)
        {
            using (var stream = response.GetResponseStream())
            {
                if (stream == null) throw new InvalidOperationException("Response Stream is null");

                try
                {
                    return new XPathDocument(stream).CreateNavigator();
                }
                catch (XmlException exception)
                {
                    throw new XmlException("Could not read HTTP Response as XML", exception);
                }
                finally
                {
                    response.Close();
                }
            }
        }
开发者ID:leetreveil,项目名称:LPFM-Last.fm-Scrobbler,代码行数:20,代码来源:WebRequestRestApi.cs

示例14: removeBT_Click

 private void removeBT_Click(object sender, RoutedEventArgs e)   //Removes a file
 {
     try
     {
         //it is assumed that the address points to a file and not a directory
         ftpRequest = (FtpWebRequest)WebRequest.Create(address + directory + lstDir.SelectedItem.ToString());
         ftpRequest.Credentials = new NetworkCredential(c_username, c_password);
         ftpRequest.Method = WebRequestMethods.Ftp.DeleteFile;
         ftpResponse = (FtpWebResponse)ftpRequest.GetResponse();
         
     }
     catch
     {
         MessageBox.Show("could not delete file: " + directory);
     }
     ftpResponse.Close();
     ftpResponse = null;
     refresh(lstDir);
 }
开发者ID:chatomusic,项目名称:ftp355,代码行数:19,代码来源:MainWindow2.xaml.cs

示例15: Read

 public override object Read(WebResponse response, Stream responseStream)
 {
     response.Close();
     return null;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:5,代码来源:NopReturnReader.cs


注:本文中的System.Net.WebResponse.Close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。