JayBeeOH

TxtEditor - Command Line Argument Passing

Apr 28th, 2015
481
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 3.18 KB | None | 0 0
  1. '------------------------------------------------------------------------------------------
  2. '           Notice of My Copyright and Intellectual Property Rights
  3. '
  4. ' Any intellectual property contained within the program by Joseph L. Bolen remains the
  5. ' intellectual property of the Joseph L. Bolen. This means that no person may distribute,
  6. ' publish or provide such intellectual property to any other person or entity for any
  7. ' reason, commercial or otherwise, without the express written permission of Joseph L. Bolen.
  8. '
  9. '                 Copyright © 2015. All rights reserved.
  10. '        All trademarks remain the property of their respective owners.
  11. '-------------------------------------------------------------------------------------------
  12. ' Program Name:   Text Editor
  13. '
  14. ' Author:         Joseph L. Bolen
  15. ' Date Created:   Feb 2015
  16. '
  17. ' Description:    Simple plain text editor program with printing ability.
  18. '
  19. '                 Documentation is at:
  20. '                   App's screen image is at: http://imgur.com/TzWs9kO
  21. '                   App's screen design time specs at: http://pastebin.com/bhinRQ5d
  22. '                   App's Visual Basic .NET Event Procedures & TODO's is at
  23. '                       http://pastebin.com/UZ4tcEpE
  24. '                   App's Visual Basic .NET code is at http://pastebin.com/u/jaybeeoh
  25. '                   Video tutorial at YouTube: http://www.youtube.com/user/bolenpresents
  26. '-------------------------------------------------------------------------------------------
  27. #Region "  Declare class level variables"
  28.  
  29.     Public applicationTitle As String = String.Empty
  30.     Private workingPathFile As String = String.Empty
  31.  
  32.     ' NOTE: Additional code not shown.
  33. #End Region
  34.  
  35. #Region "  MainForm Events"
  36.  
  37.     ' Form loads and initialization performed.
  38.     Private Sub MainForm_Load(sender As Object, e As EventArgs) _
  39.         Handles MyBase.Load
  40.  
  41.         ' Set the title of the form.
  42.         If My.Application.Info.Title <> String.Empty Then
  43.             applicationTitle = My.Application.Info.Title
  44.         Else
  45.             applicationTitle = System.IO.Path.GetFileNameWithoutExtension(My.Application.Info.AssemblyName)
  46.         End If
  47.         Me.Text = applicationTitle
  48.  
  49.         ' Command Line processing of argument - filename.
  50.         If My.Application.IsNetworkDeployed Then ' ClickOnce
  51.             ' ClickOnce file association evoked program
  52.             Dim args = AppDomain.CurrentDomain.SetupInformation.ActivationArguments
  53.             If args.ActivationData IsNot Nothing Then
  54.                 If args.ActivationData.Count > 0 Then
  55.                     workingPathFile = args.ActivationData(0)
  56.                     If File.Exists(workingPathFile) Then
  57.                         GetFile()
  58.                     End If
  59.                 End If
  60.             End If
  61.         Else
  62.             ' Traditional command line evoked with args
  63.             If My.Application.CommandLineArgs.Count > 0 Then
  64.                 workingPathFile = My.Application.CommandLineArgs(0)
  65.                 If File.Exists(workingPathFile) Then
  66.                     GetFile()
  67.                 End If
  68.             End If
  69.         End If
  70.  
  71.         ' NOTE: Additional code not shown.
  72.  
  73.     End Sub
Advertisement
Add Comment
Please, Sign In to add comment