- Home /
Question by
am_012 · Sep 01, 2020 at 03:43 AM ·
fileoutputcsvreading data
Can not output CSV file
I am trying to get the name of the object my raycast hit and at what coordinates they got hit at. outputted as data into a CSV file. However I get the following errors,
UnauthorizedAccessException: Access to the path "C:\myOutput.csv" is denied.
System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share
Is there something I must fix in my code, to stop the restriction? Here is my code
var file = @"C:\myOutput.csv";
using (var stream = File.CreateText(file))
{
string[] cars = {hit.collider.gameObject.name};
//string [] name =
//string second = image.ToString();
string csvRow = string.Format("{0},{1}", cars, screenPoint);
stream.WriteLine(csvRow);
}
Comment
Answer by GADeavid · Sep 01, 2020 at 05:28 AM
Most probably the application does not have proper permissions to create files on the C: drive. Have you tried creating the csv file in, for example the unity projects folder?
Your answer
Follow this Question
Related Questions
How to output a file to a single string? 1 Answer
How to open file csv in localdisk at runtime scene as data resources? 0 Answers
Multiple Lists to CSV in C# 0 Answers
Unity Platform Independent File I/O 1 Answer
Out put data from web version 2 Answers