This is probably a problem of permissions ( Documentation ).
You can try to open the file in the code, for example with the File.OpenRead
instruction and see if any exception jumps (by placing a try/catch
).
That exception is going to give you more information about the problem that the file has and why it can not be opened.
Example of the code to test it:
try
{
FileStream f = File.OpenRead("C:\Temp\test.txt");
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
If it is not a matter of permissions and the exception continues to give you the error that the file is not found, you should check that the file is really called test.txt
, one of the main causes is the option of Ocultar las extensiones
of the browser , that having it activated can cause confusion and that the file is really called test.txt.txt
and not test.txt
.