title: unity creating folder on desktop then saving WAV files to it
body: <p>I am making a piano game, where you press a key and it plays the corresponding note. I want to record the notes and then play it back in-game and save it as a WAV file into a folder, using OnAudioFilterRead to record. it all works in the editor but when I build the game, it still saves to the Unity game folder, I tried different things but it didn't work so I left it at "./Assets/" for now. I want to create a folder on the desktop, so i can save the WAV files in the folder. i dont know how to do that so i would appreciate any help my code is down below</p>
  
  <pre><code>using System.IO; // for FileStream
  using System; // for BitConverter and Byte Type
  using UnityEngine;
  using UnityEngine.UI;
  using System.Collections;
  using System.Collections.Generic;
  
  
  public class Record : MonoBehaviour
  {
  private int bufferSize;
  private int numBuffers;
  private int outputRate = 44100;
  private String fileName = "recTest.wav";
  private int headerSize = 44; //default for uncompressed wav
  public Button record, play;
  public ArrayList notes;
  public bool recordMode = false;
  public bool playMode;
  Animator anim;
  private static string rec;
  public AudioClip noteA;
  public AudioClip noteB;
  public AudioClip noteC;
  public AudioClip noteD;
  public AudioClip noteE;
  public AudioClip noteF;
  public AudioClip noteG;
  private FileStream fileStream;
  String Path;
  
  
  void Start()
  {
      AudioSettings.GetDSPBufferSize(out bufferSize, out numBuffers);
      anim = gameObject.GetComponent&lt;Animator&gt;();
      AudioConfiguration config = AudioSettings.GetConfiguration();
      config.sampleRate = outputRate;
      // Button rec = record.GetComponent&lt;Button&gt;();
      //Button pl = play.GetComponent&lt;Button&gt;();
  
  }
  void PlayNote (){
  
      if (Input.GetKeyDown(KeyCode.A))
      {
          GameObject.Find("Circle_A").GetComponent&lt;Animator&gt;().SetTrigger("A");
          GameObject.Find("Circle_A").GetComponent&lt;AudioSource&gt;().PlayOneShot(noteA);
      }
      if (Input.GetKeyDown(KeyCode.B))
      {
          GameObject.Find("Circle_B").GetComponent&lt;Animator&gt;().SetTrigger("B");
          GameObject.Find("Circle_B").GetComponent&lt;AudioSource&gt;().PlayOneShot(noteB);
      }
      if (Input.GetKeyDown(KeyCode.C))
      {
          GameObject.Find("Circle_C").GetComponent&lt;Animator&gt;().SetTrigger("C");
          GameObject.Find("Circle_C").GetComponent&lt;AudioSource&gt;().PlayOneShot(noteC);
      }
      if (Input.GetKeyDown(KeyCode.D))
      {
          GameObject.Find("Circle_D").GetComponent&lt;Animator&gt;().SetTrigger("D");
          GameObject.Find("Circle_D").GetComponent&lt;AudioSource&gt;().PlayOneShot(noteD);
      }
      if (Input.GetKeyDown(KeyCode.E))
      {
          GameObject.Find("Circle_E").GetComponent&lt;Animator&gt;().SetTrigger("E");
          GameObject.Find("Circle_E").GetComponent&lt;AudioSource&gt;().PlayOneShot(noteE);
      }
      if (Input.GetKeyDown(KeyCode.F))
      {
          GameObject.Find("Circle_F").GetComponent&lt;Animator&gt;().SetTrigger("F");
          GameObject.Find("Circle_F").GetComponent&lt;AudioSource&gt;().PlayOneShot(noteF);
      }
      if (Input.GetKeyDown(KeyCode.G))
      {
          GameObject.Find("Circle_G").GetComponent&lt;Animator&gt;().SetTrigger("G");
          GameObject.Find("Circle_G").GetComponent&lt;AudioSource&gt;().PlayOneShot(noteG);
  
      }
  
  }
  
  void Playback()
  {
  
  
      WWW www = new WWW("file:///"+ Application.dataPath +"/" + fileName );
      gameObject.GetComponent&lt;AudioSource&gt;().clip = www.GetAudioClip(false, true, AudioType.WAV);
      gameObject.GetComponent&lt;AudioSource&gt;().Play();
      //playMode = false;
  }
  
  public void ButtonPressed()
  
  {
  
      ColorBlock colors = record.colors;
  
          if (!recordMode)
          {
  
              colors.normalColor = Color.white;
              colors.highlightedColor = new Color32(255, 255, 255, 255);
              record.colors = colors;
  
              fileName = "Rec" + System.DateTime.Now.Second + ".wav";
              StartWriting(fileName);
              print("rec");
              recordMode = true;
      }
          else
          {
              colors.normalColor = Color.red;
              colors.highlightedColor = new Color32(225, 100, 100, 255);
              record.colors = colors;
              recordMode = false;
              WriteHeader();
              rec = fileName;
              print("Rec stop");
          }
  }
  public void PlayPressed()
  {
      ColorBlock colors = play.colors;
      if (!playMode)
      {
  
          colors.normalColor = Color.white;
          colors.highlightedColor = new Color32(255, 255, 255, 255);
          play.colors = colors;
          Playback();
          playMode = true;
  
      }
      else
      {
  
          playMode = false;
          colors.normalColor = Color.red;
          colors.highlightedColor = new Color32(225, 100, 100, 255);
          play.colors = colors;
  
      }
  
  
  }
  
  void Update()
  {
      PlayNote();
  
  }
  
  void StartWriting(String name)
  {
      fileStream = new FileStream("./Assets/" + name, FileMode.Create);
      byte emptyByte = new byte();
  
      for (int i = 0; i &lt; headerSize; i++) //preparing the header
      {
          fileStream.WriteByte(emptyByte);
      }
  }
  
  void OnAudioFilterRead(float[] data, int channels)
  {
      if (recordMode)
      {
          ConvertAndWrite(data); //audio data is interlaced
  
      }
  }
  
  void ConvertAndWrite(float[] dataSource)
  {
  
      Int16[] intData = new Int16[dataSource.Length];
      //converting in 2 steps : float[] to Int16[], //then Int16[] to Byte[]
  
      Byte[] bytesData = new Byte[dataSource.Length * 2];
      //bytesData array is twice the size of
      //dataSource array because a float converted in Int16 is 2 bytes.
  
      int rescaleFactor = 32767; //to convert float to Int16
  
      for (int i = 0; i &lt; dataSource.Length; i++)
      {
          intData[i] = (Int16)(dataSource[i] * rescaleFactor);
          Byte[] byteArr = new Byte[2];
          byteArr = BitConverter.GetBytes(intData[i]);
          byteArr.CopyTo(bytesData, i * 2);
      }
  
      fileStream.Write(bytesData, 0, bytesData.Length);
  }
  
  
  void WriteHeader()
  {
  
      fileStream.Seek(0, SeekOrigin.Begin);
  
      Byte[] riff = System.Text.Encoding.UTF8.GetBytes("RIFF");
      fileStream.Write(riff, 0, 4);
  
      Byte[] chunkSize = BitConverter.GetBytes(fileStream.Length - 8);
      fileStream.Write(chunkSize, 0, 4);
  
      Byte[] wave = System.Text.Encoding.UTF8.GetBytes("WAVE");
      fileStream.Write(wave, 0, 4);
  
      Byte[] fmt = System.Text.Encoding.UTF8.GetBytes("fmt ");
      fileStream.Write(fmt, 0, 4);
  
      Byte[] subChunk1 = BitConverter.GetBytes(16);
      fileStream.Write(subChunk1, 0, 4);
  
      UInt16 two = 2;
      UInt16 one = 1;
  
      Byte[] audioFormat = BitConverter.GetBytes(one);
      fileStream.Write(audioFormat, 0, 2);
  
      Byte[] numChannels = BitConverter.GetBytes(two);
      fileStream.Write(numChannels, 0, 2);
  
      Byte[] sampleRate = BitConverter.GetBytes(outputRate);
      fileStream.Write(sampleRate, 0, 4);
  
      Byte[] byteRate = BitConverter.GetBytes(outputRate * 4);
      // sampleRate * bytesPerSample*number of channels, here 44100*2*2
  
      fileStream.Write(byteRate, 0, 4);
  
      UInt16 four = 4;
      Byte[] blockAlign = BitConverter.GetBytes(four);
      fileStream.Write(blockAlign, 0, 2);
  
      UInt16 sixteen = 16;
      Byte[] bitsPerSample = BitConverter.GetBytes(sixteen);
      fileStream.Write(bitsPerSample, 0, 2);
  
      Byte[] dataString = System.Text.Encoding.UTF8.GetBytes("data");
      fileStream.Write(dataString, 0, 4);
  
      Byte[] subChunk2 = BitConverter.GetBytes(fileStream.Length - headerSize);
      fileStream.Write(subChunk2, 0, 4);
  
      fileStream.Close();
  }
  </code></pre>
  
  <p>}</p>