Daniel_P67
asked on
Split Commandline Arguments/parameters Into Variables
Stuck on a bit of code. We are calling a program with parameters, Example: program.exe \\server\file nameoffile pdf status. Want to take each parameter separated by a space and assign it to a string variable. On this line "string[] words = args.Split(' ');", "args" is giving me the error system.array has no definition for Split. Have not been able to get past this point.
Any help or comments are welcomed!
Any help or comments are welcomed!
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Programname : Form
{
string[] args = Environment.GetCommandLineArgs();
public Programname()
{
InitializeComponent();
}
private void OpenDrawing_Click(object sender, EventArgs e)
{
string[] words = args.Split(' ');
string docPath = words[0];
string docFile = words[1];
string docExt = words[2];
string docType = words[3];
string docStatus = words[4];
}
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Explanation was good enough to help me solve the issue. Thanks!
ASKER
Open in new window