Nogen der kan oversætte denne VB-kode til C#?
Jeg har følgende stykke kode, som jeg gerne vil have oversat til C#:' * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
' Simple script that shows how to use vbs to create/modify accounts and properties
' * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
' Define objects to use with manager
Dim Manager, Domain, Settings, User
' Consts used for accounts creation
Const LogSettings = "Default,REGULAR,""65535,65535,$DOM_NAME-$year-$mm.log"""
Const IPBinding = "*,21,ESSL" ' '',ESSL, ESSLO, ISSL
Const DomainName = "ftp.test.com"
Const UserName = "Anonymous"
Const GroupName = "Friends"
' * * * * * * Create manager object * * * * * * *
Set Manager = CreateObject("G6FTPServer.Manager")
' * * * * * * First Domain properties * * * * * *
' Show some domains properties
if Manager.Domains.Count > 0 then
s = "Status for : "&Manager.Domains.Item(0).Name&vbCRLF
s = s&" Clients : "&Manager.Domains.Item(0).Clients&vbCRLF
s = s&" Downloads : "&Manager.Domains.Item(0).Downloads&vbCRLF
s = s&" Uploads : "&Manager.Domains.Item(0).Uploads&vbCRLF
s = s&" Bandwidth : "&Manager.Domains.Item(0).Bandwidth_In&" / "
&Manager.Domains.Item(0).Bandwidth_Out
msgbox s
end if
' * * * * * * New Domain * * * * * * * * * * * *
' Check if domain already exists
Set Domain = Manager.Domains.Item(DomainName)
if Domain is Nothing then
' Add domain
Set Domain = Manager.Domains.Add(DomainName)
' Set some values
Set Settings = Domain.Properties
Settings.Values("LogList") = LogSettings
Settings.Values("IP") = IPBinding
' Apply new settings
Settings.ApplyChanges()
msgbox "Domain "&DomainName&" has been created!", VBInformation
end if
' * * * * * * New User * * * * * * * * * * * * *
Set Domain = Manager.Domains.Item(DomainName)
' Check if user already exists
if Domain.UserList.Item(UserName) is Nothing then
' Add user
Set User = Domain.UserList.Add(UserName)
' Set some values
User.Properties.Values("Enabled") = "1"
User.Properties.Values("PasswordEnabled") = "0"
'User.Properties.Values("Password") = "MD5:"+MD5("hello")
User.Properties.Values("AccessList") = "/,c:\ftproot,R,FDI"&vbCRLF&"/temp,c:\temp,R,FDI"
User.Properties.Values("IPAccessList") =
"192.168.0.*,Allowed,Local users"&vbCRLF&"192.168.0.11,Denied,Local user"
msgbox "User "&UserName&" has been created in "&DomainName&"!", VBInformation
end if
' * * * * * * New Group * * * * * * * * * * * * *
Set Domain = Manager.Domains.Item(DomainName)
' Check if group already exists
if Domain.GroupList.Item(GroupName) is Nothing then
' Add group
Set Group = Domain.GroupList.Add(GroupName)
' Set some values
Group.Properties.Values("Enabled") = "1"
Group.Properties.Values("PasswordEnabled") = "0"
Group.Properties.Values("AccessList") = "/,c:\ftproot,R,FDI"&vbCRLF&"/temp,c:\temp,R,FDI"
Group.Properties.Values("IPAccessList") =
"192.168.0.*,Allowed,Local users"&vbCRLF&"192.168.0.11,Denied,Local user"
msgbox "Group "&GroupName&" has been created in "&DomainName&"!", VBInformation
end if
' * * * * * * Delete Domain * * * * * * * * * * * * *
' Ask to delete new domain
res = msgbox ("Press OK to delete "&DomainName&" or Cancel to abort",
VBOKCancel+VBCritical, "Delete "&DomainName&" ?")
' Delete if OK
if res = VBOK then
Manager.Domains.Item(DomainName).Delete()
msgbox "Domain "&DomainName&" has been deleted!", VBInformation
end if
