IT Blog

  • Blog
  • Technology
    • Architecture
    • CMS
    • CRM
    • Web
    • DotNET
    • Python
    • Database
    • BI
    • Program Language
  • Users
    • Login
    • Register
    • Forgot Password?
  • ENEN
    • ENEN
C#
C#

Checks if the remote file exists

Language: C# /// <summary>Get remote file information</summary> /// <param name="url">The URL of the remote file</param> /// <returns>RemoteFile if the remote file exists, or null</returns> public static RemoteFile RemoteFileInfo(string url) { RemoteFile file = new RemoteFile(); try { var request = WebRequest.Create(url); request.Method = "HEAD"; using (var response = request.GetResponse() as HttpWebResponse) { file.LastModified = response.LastModified; file.Size = response.ContentLength; file.StatusCode = response.StatusCode; file.ContentType = response.ContentType; file.ContentEncoding = response.ContentEncoding; } } catch(Exception e) { return null; } return file; } public class RemoteFile { public DateTime LastModified { get; set; } public long Size { get; set; } public HttpStatusCode StatusCode { get; set; } public string ContentType { get; set; } public string ContentEncoding { get; set; } }

2020年11月19日 0条评论 195点热度 0人点赞 阅读全文
最新 热点 随机
最新 热点 随机
Generating Test Data with SQL Scripts Remote connection to MySQL on SiteGround Hide author information from WordPress How to do some trick to improve WordPress performance Recovering user role in WordPress Sending email using gmail SMTP
How to do some trick to improve WordPress performanceRemote connection to MySQL on SiteGroundGenerating Test Data with SQL ScriptsRecovering user role in WordPressHide author information from WordPress
Embed google map in a page WordPress Event Calendar 的汉化 Show any data in DataTables in WordPress Recovering user role in WordPress Unicode to Chinese conversion notes 手机邮件设定
Categories
  • AdSense
  • Architecture
  • BI
  • C#
  • CSS
  • Database
  • Digital Marketing
  • DotNET
  • Hosting
  • HTML
  • JavaScript
  • PHP
  • Program Language
  • Python
  • Security
  • SEO
  • Technology
  • Web
  • Wordpress

COPYRIGHT © 20203-2021 Hostlike.com. ALL RIGHTS RESERVED.