2009-10-29 32 views
5

Tôi muốn tạo chương trình bảng điều khiển trong VB.net để cho phép tham số. Những gì tôi muốn làm là trong mã dưới đây thêm các thông số để trang webpart có thể được tạo ra từ trình đơn Run. ví dụ. C: ....... \ MyProgram.exe "Thiết kế" - Điều này sau đó sẽ tạo ra trang Webpart thiết kế.Chương trình dòng lệnh VB.Net (bảng điều khiển) với tham số cho SharePoint

Tôi đã thử xem internet nhưng không thành công lắm. Mọi sự trợ giúp sẽ rất được trân trọng.

 Module Main 

       Public Sub Main(ByVal args As String()) 
      Dim prj As String 

        Dim site As New SPSite("http://site/") 
        Dim web As SPWeb = site.AllWebs(0) 

        Dim list As SPList = web.Lists("ListName") 

Dim postInformation As String = "<?xml version=""1.0"" encoding=""UTF-8""?><Method><SetList Scope=""Request"">" + list.ID.ToString + "</SetList><SetVar 
    Name=""ID"">New</SetVar><SetVar Name=""Cmd"">NewWebPage</SetVar><SetVar 
    Name=""Type"">WebPartPage</SetVar><SetVar Name=""WebPartPageTemplate"">2</SetVar><SetVar 
    Name=""Title"">" + prj.ToString + "</SetVar><SetVar 
    Name=""Overwrite"">true</SetVar></Method>" 

        Dim processBatch As String = web.ProcessBatchData(postInformation) 
       'Display the results... 
       Console.WriteLine(processBatch) 
        Console.WriteLine("New Web part page added successfully") 
        Console.ReadLine() 



       End Sub 

     End Module 

Cảm ơn bạn trước!

Trả lời

15
Public Sub Main(ByVal sArgs() As String) 

    If sArgs.Length = 0 Then    'If there are no arguments 
     Console.WriteLine("Hello World! <-no arguments passed->") 'Just output Hello World 
    Else         'We have some arguments 
     Dim i As Integer = 0 

     While i < sArgs.Length    'So with each argument 
      Console.WriteLine("Hello " & sArgs(i) & "!") 'Print out each item 
      i = i + 1      'Increment to the next argument 
     End While 

    End If 

End Sub 

Hy vọng điều này sẽ giúp, để truy cập vào đối số dòng lệnh.

Câu trả lời hay nhất bởi: Rajesh Sitaraman

Các vấn đề liên quan