[Windows] How to read info or path when double click a file.my extension that opens my game in C# ?

Probably this is a bit higher for my skills but lets try.

I have a C# game which works with .wav audio files. The file can be open and play from inside the game. i use a HDD url path (example: C:/music/audioClip.wav ).

 void PlayAudioClip ( string path ) { //code...

Using an installer or In windows is simple to associate this particular wav extension to my game.
You have to add registry entries in the installer to associate your program’s file extension with the game application.
So if the player makes double click into a .wav file then opens my game.
My intention is to open and run the file, that in my case read and play the file.

How do I get the path when the wav file is double click?

I found this code

public static void Main(string[] args){    
     if (args.Length == 0){
       // Show your application usage or show an error box      
       return;
     }
     string file = args[0];
     Application.Run(new MyProgram(file));   
}

But I didn’t understand it. I don’t know how to implement it in Unity.
Do I need some extra includes for Application.Run?
The string array args is the file path?
In Unity do I need to get the path in Start() or in Awake()?

Just in case a bit more about play function:

void Start () {
    StartCoroutine( PlayWAV ( hddPath ) );
}


IEnumerator PlayWAV ( string path )
{
    path = path.Replace('\\', '/');
    path = "file:///" + path;
    WWW URL = new WWW( path );
    yield return URL;
    audioSource.clip = URL.GetAudioClip(false,true);

    if (audioContainer.clip.loadState == AudioDataLoadState.Loaded &&
        path.ToLower().Contains(".wav") )
    {
        audioSource.Play();
    }
}

Environment.CommandLine looks like is not working. Gives me error:

`System.Environment’ is a type not a namespace. A using namespace directive can only be applied to namespaces.

I try to use GetCommandLineArgs() but gives me the path of my application and not the path of the file that I’m double clicking. My code is like this:

using UnityEngine;
using System.Collections;
using System;

public class Test : MonoBehaviour {

    string displayText;

    void Start()
    {
        //string[] args = System.Environment.CommandLineArgs();
        string[] args = Environment.GetCommandLineArgs();

        string path = args[0];
        if (args.Length == 0)
        {
            Debug.Log("There is no file that is trying to be opened!");
            displayText = "There is no file that is trying to be opened!";
            return;
        }
        myFunction();
        Debug.Log(args.Length.ToString());

        displayText = args[0];

        /*
        for (int i = 0; i < args.Length; i++)
        {
            Debug.Log(args[i]);
        }*/
    }
   
   
    void Update () {
   
    }

    void OnGUI()
    {
        if (GUILayout.Button(displayText))
            Debug.Log("Hello!");                //    Boton
    }

    void myFunction ()
    {
        print ("OK!");
        displayText = "There was data in the string";
       
    }

GetCommandLineArgs returns an array of items but you’re only looking at the first one. You might look to see if there are more arguments. My guess is that you’ll find the file path being one of the other arguments, though I’ve not done file association with Windows before.