RE: About send a string to a C# app

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Rakesh Rajan (RakeshRajan_at_discussions.microsoft.com)
Date: 11/16/04


Date: Mon, 15 Nov 2004 22:16:01 -0800

Hi,

Modify your Main method to accept a string array.
Checkout this code snippet:

static void Main(string[] args)
{
  if (args.Length > 0)
  {
    //check the arguments
    if (args[0].ToLower().Trim().Substring(0,2) == "/c")
    {
      ...
    }
  else // there are no arguments
  {
    ...
  }
}

HTH,
Rakesh Rajan

"cfyam" wrote:

> How can I send a string (like a file name) to a C# app when it is start
> running?
>
>
>



Relevant Pages

  • Publishing a service (.NET 4.0)
    ... static int Main(stringargs) ... install = true; break; ... static void Install ... private static void WriteToEventLog(Exception ex, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Generic and COM
    ...   static void Main(stringargs) ... app will never get the memory allocation as there is no else block. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: C# equivalent to TryCast
    ... static void Main(stringargs) ... B myclass = new B; ... if (obj is Foo) ...
    (microsoft.public.dotnet.languages.csharp)
  • Pull method for sqlceremotedataaccess
    ... catch (SqlCeException ce) ... private static void CreateDatabase() ... // Pull down the authors table from the pubs database on the remote ... internetUrl in the code snippet without any error ...
    (microsoft.public.sqlserver.ce)
  • pull method
    ... catch (SqlCeException ce) ... private static void CreateDatabase() ... // Pull down the authors table from the pubs database on the remote ... internetUrl in the code snippet without any error ...
    (microsoft.public.sqlserver.replication)