Can you help me translate this .vbs script to C#
-
Hi. I was browsing through one of the my companies PCs and found a script which would be usefull to me if it was in C#. I, personaly, dont know much of VB, thats why i ask for you - the experts - to take 5 minutes of your time and translate this little piece of code to C#. Thank you very much in advance!!!!! The code:
Set fso = CreateObject("Scripting.FileSystemObject")
Set objArgs = WScript.Arguments
Set folder = fso.GetFolder(objArgs(0))
Set tifs = folder.Files
NumberOfFiles = tifs.Count
ReDim Field(NumberOfFiles)
i = 0
For Each file In tifs
Field(i) = file.Name
i = i + 1
If i = NumberOfFiles Then
Exit For
End If
Next
destination = AddNewFolder(folder.Path, "Hrbtne")
For i = 0 To NumberOfFiles - 2
If Right(Field(i), 3) = Right(Field(i+1), 3) Then
fso.MoveFile folder.Path & "\" & Field(i), destination
fso.MoveFile folder.Path & "\" & Field(i+1), destination
End If
Next
Erase Field
EndTime = Timer
MsgBox "Čas izvajanja " & EndTime - StartTime & " sekund."
Set fso = Nothing
Set folder = Nothing
Set tifs = NothingFunction AddNewFolder(path, folderName)
Dim fso, f, fc, nf
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(path)
Set fc = f.SubFolders
Set nf = fc.Add(folderName)
AddNewFolder = nf.Path & "\"
End FunctionRegards, Matjaž
-
Hi. I was browsing through one of the my companies PCs and found a script which would be usefull to me if it was in C#. I, personaly, dont know much of VB, thats why i ask for you - the experts - to take 5 minutes of your time and translate this little piece of code to C#. Thank you very much in advance!!!!! The code:
Set fso = CreateObject("Scripting.FileSystemObject")
Set objArgs = WScript.Arguments
Set folder = fso.GetFolder(objArgs(0))
Set tifs = folder.Files
NumberOfFiles = tifs.Count
ReDim Field(NumberOfFiles)
i = 0
For Each file In tifs
Field(i) = file.Name
i = i + 1
If i = NumberOfFiles Then
Exit For
End If
Next
destination = AddNewFolder(folder.Path, "Hrbtne")
For i = 0 To NumberOfFiles - 2
If Right(Field(i), 3) = Right(Field(i+1), 3) Then
fso.MoveFile folder.Path & "\" & Field(i), destination
fso.MoveFile folder.Path & "\" & Field(i+1), destination
End If
Next
Erase Field
EndTime = Timer
MsgBox "Čas izvajanja " & EndTime - StartTime & " sekund."
Set fso = Nothing
Set folder = Nothing
Set tifs = NothingFunction AddNewFolder(path, folderName)
Dim fso, f, fc, nf
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(path)
Set fc = f.SubFolders
Set nf = fc.Add(folderName)
AddNewFolder = nf.Path & "\"
End FunctionRegards, Matjaž
If you know C# that really wouldn't be that difficult. Also, this is not quite the right forum for that kind of question. How about you get it as far as you can, and ask for help when you get stuck.
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
-
If you know C# that really wouldn't be that difficult. Also, this is not quite the right forum for that kind of question. How about you get it as far as you can, and ask for help when you get stuck.
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
Umm... yes, VB.Net and C# are pretty similar, but old VB and VBS are not. At least not to me, as i started with C# and am planning to stay around .NET environment. As time is precious, i understand that no help was given really and its ok. I googled a bit, just for kicks, for a VB to C# translator and found a site http://www.carlosag.net/Tools/CodeTranslator/[^] which explained most of the things to me. So, thanks anyway.
Regards, Matjaž
-
Umm... yes, VB.Net and C# are pretty similar, but old VB and VBS are not. At least not to me, as i started with C# and am planning to stay around .NET environment. As time is precious, i understand that no help was given really and its ok. I googled a bit, just for kicks, for a VB to C# translator and found a site http://www.carlosag.net/Tools/CodeTranslator/[^] which explained most of the things to me. So, thanks anyway.
Regards, Matjaž
-
Thats for VB.Net to C#, VBS, VB6 and under are ENTIRELY different languages, and no one here will convert code like that into .net code. Good luck finding anyone to do pretty much any substantial coding for you around here.
lol. Thats really a NO!!! Not really a nice message. I just asked for someone to give 5 minutes of his time to me. Nothing big for someone, but for you its like giving your virginity to me. Tough times i gues... Thanks anyway. Like i said... I managed to convert it to C# :P
Regards, Matjaž
-
lol. Thats really a NO!!! Not really a nice message. I just asked for someone to give 5 minutes of his time to me. Nothing big for someone, but for you its like giving your virginity to me. Tough times i gues... Thanks anyway. Like i said... I managed to convert it to C# :P
Regards, Matjaž
Matjaž Grahek wrote:
Not really a nice message.
Not really a smart question either.
Matjaž Grahek wrote:
I just asked for someone to give 5 minutes of his time to me. Nothing big for someone, but for you its like giving your virginity to me. Tough times i gues...
Do you know how many people ask for "five minutes" of peoples time around here? It's not like giving away anyone's virginity, it's like I'm giving away five minutes. Read on forum etiquette a bit before you act like an ass.