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


C# WebClient.OpenWrite方法代码示例

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


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

示例1: WriteHtml

 /// <summary>
 /// 写页面
 /// </summary>
 public static void WriteHtml()
 {
     WebClient client = new WebClient();
     Stream stream = client.OpenWrite("E:/XBoom/GodWay/GodWay1/Web/Log/newfile.txt","PUT");
     StreamWriter streamWrite = new StreamWriter(stream);
     streamWrite.WriteLine("Hello World");
     streamWrite.Close();
 }
开发者ID:XBoom,项目名称:GodWay,代码行数:11,代码来源:BasicWebClient.cs

示例2: OpenWriteAsync

 protected override Task<Stream> OpenWriteAsync(WebClient wc, string address) => Task.Run(() => wc.OpenWrite(address));
开发者ID:Corillian,项目名称:corefx,代码行数:1,代码来源:WebClientTest.cs

示例3: OpenWrite_InvalidArguments_ThrowExceptions

        public static void OpenWrite_InvalidArguments_ThrowExceptions()
        {
            var wc = new WebClient();

            Assert.Throws<ArgumentNullException>("address", () => { wc.OpenWrite((string)null); });
            Assert.Throws<ArgumentNullException>("address", () => { wc.OpenWrite((string)null, null); });
            Assert.Throws<ArgumentNullException>("address", () => { wc.OpenWrite((Uri)null); });
            Assert.Throws<ArgumentNullException>("address", () => { wc.OpenWrite((Uri)null, null); });
        }
开发者ID:Corillian,项目名称:corefx,代码行数:9,代码来源:WebClientTest.cs

示例4: UpLoadFile

 public bool UpLoadFile(string fileNameFullPath, string strUrlDirPath)
 {
     string str = fileNameFullPath.Substring(fileNameFullPath.LastIndexOf(@"\") + 1);
     string str2 = DateTime.Now.ToString("yyyyMMddhhmmss") + DateTime.Now.Millisecond.ToString() + fileNameFullPath.Substring(fileNameFullPath.LastIndexOf("."));
     str.Substring(str.LastIndexOf(".") + 1);
     if (!strUrlDirPath.EndsWith("/"))
     {
         strUrlDirPath = strUrlDirPath + "/";
     }
     if (Directory.Exists(base.Server.MapPath(strUrlDirPath)))
     {
         Directory.CreateDirectory(base.Server.MapPath(strUrlDirPath));
     }
     strUrlDirPath = strUrlDirPath + str2;
     WebClient client = new WebClient
     {
         Credentials = CredentialCache.DefaultCredentials
     };
     FileStream input = new FileStream(fileNameFullPath, FileMode.Open, FileAccess.Read);
     BinaryReader reader = new BinaryReader(input);
     try
     {
         byte[] buffer = reader.ReadBytes((int)input.Length);
         Stream stream2 = client.OpenWrite(strUrlDirPath, "PUT");
         if (stream2.CanWrite)
         {
             stream2.Write(buffer, 0, buffer.Length);
         }
         stream2.Close();
         return true;
     }
     catch (Exception)
     {
         return false;
     }
 }
开发者ID:SoMeTech,项目名称:SoMeRegulatory,代码行数:36,代码来源:SSMx.aspx.cs


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