C#/フォルダのCIFS共有
をテンプレートにして作成
Search in
this wiki
and
or
[
トップ
] [
新規
|
一覧
|
単語検索
|
最終更新
|
ヘルプ
]
開始行:
#ref(sharefolder.png,right,around);
一応説明すると、[[CIFS:http://www.itmedia.co.jp/dict/ne...
簡単にフォルダをネットワーク内で共有できるようにするア...
[[WSHの場合>WSH/フォルダのCIFS共有]]と比較してみてくだ...
#contents
#br
*** WMI(Windows Management Instrumentation)を使う
.NETらしさを損なわない方法。NTドメインに対応していたり...
ManagementPath path = new ManagementPath();
// remote server NetBios name or host name
path.Server = "{computername}";
path.NamespacePath = @"root\CIMV2";
path.RelativePath = @"Win32_Share";
ConnectionOptions co = new ConnectionOptions();
// account with WMI access privileges on remote server
// (Remote enabled, execute methods ....)
//co.Username = "{username}";
//co.Password = "{userpassword}";
// downlevel domain name or server name if local account
//co.Authority = "NTLMDOMAIN:domainname";
ManagementScope scope = new ManagementScope(path, co);
ManagementClass mc = new ManagementClass(scope, path, nu...
ManagementBaseObject inParams = mc.GetMethodParameters("...
inParams["Name"] = "share_name";
inParams["Path"] = @"d:\share_folder";
inParams["Type"] = 0;
inParams["Access"] = null;
inParams["Description"] ="共有フォルダの説明";
inParams["MaximumAllowed"] = 5;
ManagementBaseObject mbo = mc.InvokeMethod("Create", inP...
uint result = (uint) mbo.Properties["ReturnValue"].Value;
// 0 = success
*** Win32API(NetApi32.dll)を使う
旧APIを使う方法もあります。次期WindowsからWin32APIが無...
#ref(NetApi32.cs);
*** Windows Scripting Host Network object(WshNetwork)を使う
WSHはこの辺の機能を独自に実装しています。COMとして公開...
利用法は、WSH関連ページとして近日公開。
終了行:
#ref(sharefolder.png,right,around);
一応説明すると、[[CIFS:http://www.itmedia.co.jp/dict/ne...
簡単にフォルダをネットワーク内で共有できるようにするア...
[[WSHの場合>WSH/フォルダのCIFS共有]]と比較してみてくだ...
#contents
#br
*** WMI(Windows Management Instrumentation)を使う
.NETらしさを損なわない方法。NTドメインに対応していたり...
ManagementPath path = new ManagementPath();
// remote server NetBios name or host name
path.Server = "{computername}";
path.NamespacePath = @"root\CIMV2";
path.RelativePath = @"Win32_Share";
ConnectionOptions co = new ConnectionOptions();
// account with WMI access privileges on remote server
// (Remote enabled, execute methods ....)
//co.Username = "{username}";
//co.Password = "{userpassword}";
// downlevel domain name or server name if local account
//co.Authority = "NTLMDOMAIN:domainname";
ManagementScope scope = new ManagementScope(path, co);
ManagementClass mc = new ManagementClass(scope, path, nu...
ManagementBaseObject inParams = mc.GetMethodParameters("...
inParams["Name"] = "share_name";
inParams["Path"] = @"d:\share_folder";
inParams["Type"] = 0;
inParams["Access"] = null;
inParams["Description"] ="共有フォルダの説明";
inParams["MaximumAllowed"] = 5;
ManagementBaseObject mbo = mc.InvokeMethod("Create", inP...
uint result = (uint) mbo.Properties["ReturnValue"].Value;
// 0 = success
*** Win32API(NetApi32.dll)を使う
旧APIを使う方法もあります。次期WindowsからWin32APIが無...
#ref(NetApi32.cs);
*** Windows Scripting Host Network object(WshNetwork)を使う
WSHはこの辺の機能を独自に実装しています。COMとして公開...
利用法は、WSH関連ページとして近日公開。
ページ名: