I am writting an app to dump content into files.
The flow, so far is this:
1 - User enters a Path
2 - App checks if the Directory Exists and if i have Writting Permissions
2.a - If if exists, creates a empty file inside and closes it
2.b - If it does not, creates the directory and the file inside it, and closes the file
The problem is, once i reach the point when i actually have to write content in this file i previously created i can’t write a single line , it throws me a “Access to Path Denied”.
Here is the code snippet related to the issue :
// Writting ImgPixels to file
if (BDC.BDCCommons.CommonUtils.DirectoryHasWritePermissions(folderPath))
{
using (StreamWriter filePointer = File.AppendText(folderPath))
{
filePointer.WriteLine(imgPixels);
}
}
else
{
LogWriter.Error ("Permissão Negada", "Diretorio [ " + folderPath + "] nao tem permissao de escrita");
}
What might be causing this ?!
Thanks in advance Guys
Improving Question:
@500 – Internal Server Error : folderPath is the Path to the Folder,yes.
I Guess i see where is my mistake. There is no file to be written, just a folder. My Bad
Change:
to