jeudi 19 février 2015

Trying to make a txt file of a list using a webpart



I'm using a sandboxed solution, this is the error i got when i try to make the txt


Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. sharepoint


This is the code I have for creating and writting on the file



string path = @"C:\pruebas\" + txtNombre.Text + ".txt";
if (!File.Exists(path))
{
using (StreamWriter sw = File.CreateText(path))//here happens the error
{
sw.WriteLine("Hello");
sw.WriteLine(Texto);
}
}
using (StreamReader sr = File.OpenText(path))
{
string s = "";
while ((s = sr.ReadLine()) != null)
{
Console.WriteLine(s);
}
}







0 commentaires:

Enregistrer un commentaire