ファイルサーバにアクセスするように設定します。http IIS Webサイト

 

1は、最初のオープンインターネットインフォメーションサービス(IIS)マネージャは、Windowsの機能をオンに全くインターネットインフォメーションサービス(IIS)マネージャが存在しない場合は、[コントロールパネル\プログラム\プログラムと機能に基づいて、コントロールパネルを追加することができ、新しいサイトを選択しクリックしてください[OK]をクリックし、すべてのチェックボックス、インターネットの情報を追加して、以下のように、前に持っていたオープンなインターネット情報サービスを終了するには、インストールを待ちます

 

HTTPテストサイト展開ファイルサーバ:2、などのウェブサイトなどの情報を記入し、サイトがフォームをポップアップ追加し、右のサイトを追加し、サイトを選択し、サイトを追加

 

[機能ビューに切り替え3.ダブルクリックし、右側のディレクトリブラウジングエリアを、有効にする]をクリックします。

 

 

 

 4、同様のビューの切り替え機能、ダブルWebDAVの作成ルール、ルール作成右地域を選択し追加します

 

 

、ソースを読んで、すべてのチェックボックスを作成して、[OK]をクリックする権限の下で、すべてのユーザーを選択します。

 

 要求のフィルタリングの動作や行動属性設定右側の領域WebDAV設定を選択し、適切なアプリケーションをクリックしてください

 

HTTPのファイルサーバーを展開し、機能的なビューをクリックし、右側のエリアのWebDAVをクリックしてウェブサイトのテストサイトで有効にする]を選択します

 

 5、同じビューに電源スイッチ、ダブルクリックの認証は、匿名認証とWindows認証を有効にします

 

 

 

以下に示すようにしても成功した場合6は、サイトのテストサイトhttpは、ファイルサーバー、右管理Webブラウザを配備選択し、ブラウザは、web.configファイルを表示します。

フォルダTestHttpDeployFileServerの下に\アクセスTestHttpDeployFileServerファイル:7、Dをユーザーを追加し、Webサイトの物理パスを設定

ユーザーの追加:[マイコンピュータ]または[コンピュータ]を選択し、右管理デスクトップ上に、ローカルユーザーグループ、ユーザーを選択し、右の場所に、右の空白の新規ユーザーを、

 追加するmyjjユーザーダブルクリックは、ユーザーがユーザーをパワーに属する設定しました

 

フォルダTestHttpDeployFileServer下のファイルに\ TestHttpDeployFileServerアクセス​​:Webサイトの物理パスDを設定します。

选择文件夹TestHttpDeployFileServer,右键属性,选择 安全 设置myjj用户所属用户组的权限即可,如果没有 Power Users用户组,就选择 添加 高级 立即查找,然后选择 Power Users点击确定,即可设置访问权限

 

 

 

8、经过上述步骤,一个网站的http访问的文件服务器已经架设成功了,下面就可以使用了,具体如下

 新建控制台项目程序,Program.cs内容如下:

using System;
using System.Collections.Generic;
using System.Net;
using System.Text;

namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
TestWebclient testWebclient = new TestWebclient();
testWebclient.WebClientUpload();//上传
testWebclient.WebClientDownload();//下载
testWebclient.WebClientdelete();//删除
//WebClientDownload();//下载
//WebClientUpload();//上传
//WebClientDelete();//删除
Console.ReadKey();
}

#region 下载
/// <summary>
/// 下载
/// </summary>
static void WebClientDownload()
{
WebClient webClient = new WebClient
{
Credentials = CredentialCache.DefaultCredentials
};
//Uri _uri = new Uri(@"http://localhost:8082/123.txt");
Uri uri = new Uri(@"http://192.168.0.100:8082/123.txt");
webClient.DownloadProgressChanged += WebClient_DownloadProgressChanged;
webClient.DownloadFileCompleted += WebClient_DownloadFileCompleted;
webClient.DownloadFileAsync(uri, @"D:\download\123.txt");
}

private static void WebClient_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
{
Console.WriteLine("下载完成...");
}

private static void WebClient_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
Console.WriteLine($"{e.ProgressPercentage}:{e.BytesReceived}/{e.TotalBytesToReceive}");
}

#endregion

#region 上传

/// <summary>
/// 上传
/// </summary>
static void WebClientUpload()
{
WebClient webClient = new WebClient
{
Credentials = new NetworkCredential("test", "123")
};
Uri uri = new Uri(@"http://192.168.0.100:8082/456.xlsx");
webClient.UploadProgressChanged += WebClient_UploadProgressChanged;
webClient.UploadFileCompleted += WebClient_UploadFileCompleted;
webClient.UploadFileAsync(uri, "PUT", @"D:\download\456.xlsx");
}

private static void WebClient_UploadFileCompleted(object sender, UploadFileCompletedEventArgs e)
{
Console.WriteLine("上传完成...");
}

private static void WebClient_UploadProgressChanged(object sender, UploadProgressChangedEventArgs e)
{
Console.WriteLine($"{e.ProgressPercentage}:{e.BytesSent}/{e.TotalBytesToSend}");
}
#endregion

#region 删除
/// <summary>
/// 删除
/// </summary>
static void WebClientDelete()
{
WebClient webClient = new WebClient
{
Credentials = new NetworkCredential("test", "123")
};
Uri uri = new Uri(@"http://192.168.0.100:8082/456.xlsx");
webClient.UploadDataCompleted += WebClient_UploadDataCompleted;
webClient.UploadDataAsync(uri, "DELETE", new byte[0]);
}

private static void WebClient_UploadDataCompleted(object sender, UploadDataCompletedEventArgs e)
{
Console.WriteLine("已删除...");
}
#endregion
}

}

 

TestWebclient类代码如下:

using System;
using System.Collections.Generic;
using System.Net;
using System.Text;

namespace ConsoleApp1
{
public class TestWebclient
{
#region 下载
public void WebClientDownload()
{
WebClient webClient = new WebClient();
webClient.Credentials = CredentialCache.DefaultCredentials;
Uri uri = new Uri(@"http://localhost:8087/123.txt");

webClient.DownloadProgressChanged += WebClient_DownloadProgressChanged;
webClient.DownloadDataCompleted += WebClient_DownloadDataCompleted;
webClient.DownloadFileAsync(uri, @"D:\download\123.txt");
}

private static void WebClient_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
Console.WriteLine($"已下载百分比:{e.ProgressPercentage}:{e.BytesReceived / e.TotalBytesToReceive}");
}

private static void WebClient_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
{
Console.WriteLine("下载完成...");
}

#endregion

#region 上传
public void WebClientUpload()
{
WebClient webClient = new WebClient();
//webClient.Credentials = new NetworkCredential("test123","123");
webClient.Credentials = CredentialCache.DefaultCredentials;
Uri uri = new Uri(@"http://localhost:8087/456.xlsx");

webClient.UploadProgressChanged += WebClient_UploadProgressChanged;
webClient.UploadFileCompleted += WebClient_UploadFileCompleted;
webClient.UploadFileAsync(uri, "put", @"D:\download\456.xlsx");
}

private void WebClient_UploadFileCompleted(object sender, UploadFileCompletedEventArgs e)
{
Console.WriteLine("上传完成");
}

private void WebClient_UploadProgressChanged(object sender, UploadProgressChangedEventArgs e)
{
Console.WriteLine($"{e.ProgressPercentage}:{e.BytesSent/e.TotalBytesToSend}");
}
#endregion

#region 删除
public void WebClientdelete()
{
WebClient webClient = new WebClient();
webClient.Credentials = new NetworkCredential("test123","123");
//webClient.Credentials = CredentialCache.DefaultCredentials;
Uri uri = new Uri(@"http://localhost:8087/456.xlsx");

webClient.UploadDataCompleted += WebClient_UploadDataCompleted;
webClient.UploadDataAsync(uri, "DELETE", new byte[0]);
}

private void WebClient_UploadDataCompleted(object sender, UploadDataCompletedEventArgs e)
{
Console.WriteLine("已删除");
}
#endregion
}
}

おすすめ

転載: www.cnblogs.com/1175429393wljblog/p/11210973.html