title: Can I write a file to a folder on a server machine from a Web API app running on it?
body: <p>I have this code in my Web API app to write to a CSV file:</p>
  
  <pre><code>private void SaveToCSV(InventoryItem invItem, string dbContext)
  {
      string csvHeader = "id,pack_size,description,vendor_id,department,subdepartment,unit_cost,unit_list,open_qty,UPC_code,UPC_pack_size,vendor_item,crv_id";
  
      int dbContextAsInt = 0;
      int.TryParse(dbContext, out dbContextAsInt);
      string csvFilename = string.Format("Platypus{0}.csv", dbContextAsInt);
  
      string csv = string.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12}", invItem.ID,
          invItem.pksize, invItem.Description, invItem.vendor_id, invItem.dept, invItem.subdept, invItem.UnitCost,
          invItem.UnitList, invItem.OpenQty, invItem.UPC, invItem.upc_pack_size, invItem.vendor_item, invItem.crv_id);
  
      string existingContents;
      using (StreamReader sr = new StreamReader(csvFilename))
      {
          existingContents = sr.ReadToEnd();
      }
  
      using (StreamWriter writetext = File.AppendText(csvFilename))
      {
          if (!existingContents.Contains(csvHeader))
          {
              writetext.WriteLine(csvHeader);
          }
          writetext.WriteLine(csv);
      }
  }
  </code></pre>
  
  <p>On the dev machine, the csv file is saved to "C:\Program Files (x86)\IIS Express" by default. In preparation for when it is deployed to its final resting/working place, what do I need to do to get the file to save, e.g., to the server's "Platypi" folder - anything special? Do I have to specifically set certain folder persimmons to allow writing to "Platypi."</p>
  
  <p>Is it simply a matter of changing this line:</p>
  
  <pre><code>string csvFilename = string.Format("Platypus{0}.csv", dbContextAsInt);
  </code></pre>
  
  <p>...to this:</p>
  
  <pre><code>string csvFilename = string.Format(@"\Platypi\Platypus{0}.csv", dbContextAsInt);
  </code></pre>
  
  <p>?</p>