2
I am with a program created in Visual Studio / Windows Forms. In it access the following file to get some information:
1st Code (works normal)
StreamReader file = new StreamReader(@ "E:\OneDrive\VisualStudio\codigosAIH\codigosAIH\bin\Debug\tb_cid.txt", Encoding.GetEncoding("iso-8859-1"));
I changed the code for the program to search the file in the installation folder:
2º Code (gives access error denied)
StreamReader file = new StreamReader(Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory.ToString() + @"\tb_cid.txt"), Encoding.GetEncoding("iso-8859-1"));
In doing so, I get the Access to path error denied. I have used a Messagebox to confirm the path and it is correct.
I don’t think it’s a permission issue, otherwise I wouldn’t be able to access it in the form of the first code.
What can it be?
What is the first example?
– Maniero
I refer to the first code with the full written address
– Italo Rodrigo
There’s only one little piece of code in there, is he first? If he is, what’s second?
– Maniero
amended the post, ask you to look again ^^
– Italo Rodrigo
You are wanting to open the txt?
– Gabriel Heguedusch
yes, I want to read the file. (I didn’t post the rest of the code because everything works normal, only this line gives error when I try to get the file path)
– Italo Rodrigo
Please stop using the tag
visual-studio
in your questions that are not about Visual Studio =D– Jéf Bueno
honestly now I thought I should use. sorry again
– Italo Rodrigo
The first is not a code, it is a loose address. If you put this and try to compile with C# it will give error because this is not a code.
– Maniero
got it. I referred the wrong way. corrected again
– Italo Rodrigo