473,394 Members | 1,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

how to pass arguments from a c# console applucation to a windows forms application

i am trying to call a windows forms application form a console application in which the text box has to be defaultly populated with the path i am passing
Thanks in advance
Nov 5 '09 #1
1 2645
tlhintoq
3,525 Expert 2GB
A quick Google for "C# pass arguments between applications"
Found me this, as well as other tips.

Expand|Select|Wrap|Line Numbers
  1. System.Diagnostics.ProcessStartInfo otherApp = new System.Diagnostics.ProcessStartInfo("file.exe");
  2.  
  3. otherApp.Arguments = "args here";
  4.  
  5. Process.Start(otherApp);


in the Arguments property, insert there the arguments you want to give your other application. It will then recieve it and if its your own application you can either modify the main() method of it to accept the string[] arguments/parameters:

Expand|Select|Wrap|Line Numbers
  1. static void Main(string[] args)
  2.         {
  3.  
  4.             if (args.Length > 0)
  5.             {
  6.                 Console.Write("args length: " + args.Length.ToString());
  7.                 Console.Write("\n\n");
  8.                 foreach (string curArg in args)
  9.                 {
  10.                     Console.WriteLine(curArg);
  11.                 }
  12.             }
  13.             else
  14.             {
  15.                 Console.WriteLine("No args supplied");
  16.             }
  17.  
  18.         }


as an example. Or you can use the Environment.GetCommandLineArgs(); which returns a string[] array of arguments given to the application.
Please let us know if this helped you.
Nov 5 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: James Carnley | last post by:
I am learning how to use windows forms and I have come across a small problem. Whenever I run my program it opens a console window before launching the windows form. The console doesnt go away...
4
by: christopher green | last post by:
I have a solution that comprises a web based project and a console application. Web.Config holds attributes that I want to access from my console application, can anyone advise me as to how to do...
4
by: Ron | last post by:
Greetings, below is a sample app for connecting to a mainframe server using Sockets for the purpose of using FTP service to interact with it from a PC. I got as far as creating the connection....
1
by: Daryll Shatz | last post by:
Can someone point me to some information on how to include application command line arguments with a Windows application. Can this still be done in VB .NET? Thanks
12
by: Jarod_24 | last post by:
I got a project called "Forms" that hold some forms and stuff in my solution. A argument at startup defines wether to use a From or Console. My plan was to create a myConsole class that would...
8
by: Alison | last post by:
Hi, Al I am trying to design a user interface which provides both menus and toolbars for some users to click on whatever they want to do, at the same time, I would like to have a console window...
3
by: Dean Slindee | last post by:
I have a exception handling class that could be called from either a windows project app or a console project app. Is there any way for this class to determine which type of app called it without...
12
by: Dilip | last post by:
Hi All I have a server based C# console application. This application must hide its console window when its launched out on the field. So I dutifully P/Invoke'd FindWindow/ShowWindow...
12
by: raylopez99 | last post by:
Keywords: scope resolution, passing classes between parent and child forms, parameter constructor method, normal constructor, default constructor, forward reference, sharing classes between forms....
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.