复制代码 代码如下:
Uri uri = new Uri(targetUrl);//targetUrl对应文件的绝对路径
System.Net.HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
request.Method = "PUT";
request.Credentials = System.Net.CredentialCache.DefaultCredentials;
request.ContentLength = stream.Length;
复制代码 代码如下:
Uri uri = WebHelper.ProcessSpecialCharacters(targetUrl);//targetUrl对应文件的绝对路径
System.Net.HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
request.Method = "PUT";
request.Credentials = System.Net.CredentialCache.DefaultCredentials;
request.ContentLength = stream.Length;
/// <summary>
/// 当上传或下载的文件名包含有特殊字符"#"时,需要执行以下的函数进行处理
/// </summary>
/// <param></param>
/// <returns></returns>
private static Uri ProcessSpecialCharacters(string Url)
{
Uri uriTarget = new Uri(Url);
if (!Url.Contains("#"))
{
return uriTarget;
}
UriBuilder msPage = new UriBuilder();
msPage.Host = uriTarget.Host;
msPage.Scheme = uriTarget.Scheme;
msPage.Port = uriTarget.Port;
msPage.Path = uriTarget.LocalPath + uriTarget.Fragment;
msPage.Fragment = uriTarget.Fragment;
Uri uri = msPage.Uri;
return uri;
}
Uri uri = new Uri(targetUrl);//targetUrl对应文件的绝对路径
新闻热点
疑难解答
图片精选