473,320 Members | 1,865 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,320 software developers and data experts.

Getting args array from files launch through file association

I've got a process engine written in .Net. the user writes a data file and
saves it as file type ".xyz". I have a file assiciation set up in the
database that when a .xyz file is invoked (double click or called in cmd
prompt) it passed to my process engine executable as a cmd line parm.

so the process engine gets one argument, which is the path to the .xyz file.
this is standard stuff.

what i'd like to do is call the .xyz file via the command prompt and pass in
several input parms. like so:

myfile.xyz thing1 thing2 thing3

when this gets executed, the process engine should get an arg array (in the
Main function) that has 4 elements. the first one is the path, and the last
three are the arguments.

But, the process engine only gets the path. thing 1-3 are lost.

is there anyway i can get these items in the arg list for the Main function?

the only way i can think is to get rid of the file assiciation and you have
to call the engine exe with the path of the data file as the first arg, and
all other arguments later. I'd really rather not do this though.

thanks
Nov 17 '05 #1
1 1981
Hi John...
Sorry because I don't speak English very well but I will try to show my
suggestion:

You can create a Process object and pass in those parameters. See the
example below:

Process myProcess = new Process();
myProcess.StartInfo.FileName = "myfile.xyz";
myProcess.StartInfo.CreateNoWindow = true;
myProcess.StartInfo.Arguments = "thing1 thing2 thing3";
myProcess.Start();

You can build the string with all arguments then you get the file path.
See more about Process class.

Test the example below (create two console applications):

Caller Program:
using System;
using System.Diagnostics;
using System.ComponentModel;

namespace MyProcessSample{

public class MyProcess{
public static void Main(){

Process myProcess = new Process();
myProcess.StartInfo.FileName = "c:\\temp\\ConsoleApplication10.exe";
myProcess.StartInfo.Arguments = "teste1";
myProcess.Start();

}
}
}

Called program:
using System;

namespace ConsoleApplication10{
class Class1{
[STAThread]
static void Main(string[] args)
{
Console.WriteLine(args[0]);
Console.ReadLine();
}
}
}
bye.

"john conwell" wrote:
I've got a process engine written in .Net. the user writes a data file and
saves it as file type ".xyz". I have a file assiciation set up in the
database that when a .xyz file is invoked (double click or called in cmd
prompt) it passed to my process engine executable as a cmd line parm.

so the process engine gets one argument, which is the path to the .xyz file.
this is standard stuff.

what i'd like to do is call the .xyz file via the command prompt and pass in
several input parms. like so:

myfile.xyz thing1 thing2 thing3

when this gets executed, the process engine should get an arg array (in the
Main function) that has 4 elements. the first one is the path, and the last
three are the arguments.

But, the process engine only gets the path. thing 1-3 are lost.

is there anyway i can get these items in the arg list for the Main function?

the only way i can think is to get rid of the file assiciation and you have
to call the engine exe with the path of the data file as the first arg, and
all other arguments later. I'd really rather not do this though.

thanks

Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Anders Eriksson | last post by:
Hello! I'm a beginner at PHP and I wonder how I would go about to read a textfile into an array(hash). The textfile looks like this: A/S=age/sex? A/S/L=age/sex/location? AA=alcoholics...
1
by: Tim::.. | last post by:
Can someone please tell me why when ever I view a PDF file through my web application the file opens in notepad... I have checked my file association and the client machine is set to launch...
23
by: sandy | last post by:
I need (okay, I want) to make a dynamic array of my class 'Directory', within my class Directory (Can you already smell disaster?) Each Directory can have subdirectories so I thought to put these...
8
by: =?Utf-8?B?Umlja0Q=?= | last post by:
Suddenly I find myself unable to open Winforms files in designer mode. I get the message quoted below. I can open other types of vb files like modules, classes and code behind files, but simply...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.