<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                # 方法調用 ``` string dtpath = DateTime.Now.ToString("yyyyMMdd"); string dtname = DateTime.Now.ToString("yyyyMMddHHmmssfff_" + Operation.Number(8)); string filepath = context.Server.MapPath("~\\upload\\image\\" + dtpath + ""); filepath = (filepath.IndexOf("~") > -1) ? context.Server.MapPath(filepath) : filepath; HttpFileCollection files = context.Request.Files; if (!Directory.Exists(filepath))//如果文件夾不存在創建文件夾 Directory.CreateDirectory(filepath); string filepaths = context.Server.MapPath("~\\upload\\image\\" + dtpath + "\\" + dtname + ".jpg"); string namepath = "/upload/image/" + dtpath + "/" + dtname + ".jpg"; bool li = SrcLoadImg.SavePhotoFromUrl(filepaths, imgsrcArr[i]); ``` # 代碼 ``` using System; using System.IO; using System.Net; namespace NetWing.Common { public static class SrcLoadImg { /// <summary> /// 從Url保存圖片到本地 /// </summary> /// <param name="FileName">文件名</param> /// <param name="Url">遠程地址</param> /// <returns></returns> public static bool SavePhotoFromUrl(string FileName, string Url) { bool value = false; WebResponse response = null; Stream stream = null; try { WebRequest request = WebRequest.Create(Url); response = request.GetResponse(); stream = response.GetResponseStream(); if (!response.ContentType.ToLower().StartsWith("text/")) { value = SaveBinaryFile(response, FileName); } } catch (Exception e) { string aa = e.ToString(); CWriteLogs.WriteLogsE("Logs", "Error >> SavePhotoFromUrl", e.Message); } return value; } private static bool SaveBinaryFile(WebResponse response, string FileName) { bool Value = true; byte[] buffer = new byte[1024]; try { if (!File.Exists(FileName)) { Stream outStream = System.IO.File.Create(FileName); Stream inStream = response.GetResponseStream(); int l; do { l = inStream.Read(buffer, 0, buffer.Length); if (l > 0) outStream.Write(buffer, 0, l); } while (l > 0); outStream.Dispose(); outStream.Close(); inStream.Close(); } } catch (Exception e) { Value = false; CWriteLogs.WriteLogsE("Logs", "Error >> SaveBinaryFile", e.Message); } return Value; } } } ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看