I need to read a csv file in my webservice,
here is my code so far :
[WebMethod]
public List<string> getIdentifiants()
{
List<string> listA = new List<string>();
List<string> listB = new List<string>();
using (var fs = File.OpenRead(@"C:\Users\stag01\Desktop\identifiants.csv"))
using (var reader = new StreamReader(fs))
{
while (!reader.EndOfStream)
{
var line = reader.ReadLine();
var values = line.Split(';');
listA.Add(values[0]);
listB.Add(values[1]);
}
}
return listA;
}
But when I try to run it, I got this error :
System.Security.SecurityException: Échec de la demande d'autorisation de type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
à System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)
à System.Security.CodeAccessPermission.Demand()
à System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
à System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
à System.IO.File.OpenRead(String path)
à WebApplication1.WS_stage_2017.getIdentifiants() dans \Nas-server\User Folder\stag01\Mes documents\Visual Studio 2017\Projects\WebApplication1\WebApplication1\WS_stage_2017.asmx.cs:ligne 31
can anyone help me please ?