I am trying to write into csv file using Kent.Boogaart.KBCsv, cant figure out what could be the problem?
Piece of code:
private static void SaveCSV(List<AData> items,string fName)
{
using (CsvWriter wr = new CsvWriter(fName))
{
wr.ValueSeparator = ';';
foreach (AData item in items)
{
wr.WriteDataRecord(item);
}
}
}
Exception:
The process cannot access the file ‘C:\Users\myname\Documents\something.txt’ because it is being used by another process.
It’s in use by another process. That means either:
You have the file opened elsewhere and therefor cannot modify it (make sure to close Notepad and other text editors)
Possibly a mixed up complaint about Admin rights. C:\User should be protected by Windows 7 and if your process isn’t elevated, it won’t be allowed to access it. Try writing to:
C:\something.txt
Instead.