1

I have two computers connected to a wireless network with no password.

The files are on computer A and the program is on computer B.

From the OS I can access and modify the files in A from B with no problem:

enter image description here

And when I run the program:

using (StreamReader sr = new StreamReader("\\\\VIERNES7-3\\Documentos c\\tables\\tableOrders"))
            {
                String line;

                while ((line = sr.ReadLine()) != null)
                {
                    activeTables.Add(int.Parse(line));
                }
            }

It gives me the following exception:

No se controló System.UnauthorizedAccessException
  Message=Access to the path '\\VIERNES7-3\Documentos c\tables\tableOrders' is denied.
  Source=mscorlib
  StackTrace:
       at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
       at 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, Boolean useLongPath)
       at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
       at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize)
       at System.IO.StreamReader..ctor(String path)
       at cocina2.Table.ActiveTables() in C:\Users\Trufa\documents\visual studio 2010\Projects\Viernes 7\cocina2\Table.cs:line 16
       at cocina2.Form1.paintListViews() in C:\Users\Trufa\documents\visual studio 2010\Projects\Viernes 7\cocina2\Form1.cs:line 46
       at cocina2.Form1.refresh() in C:\Users\Trufa\documents\visual studio 2010\Projects\Viernes 7\cocina2\Form1.cs:line 247
       at cocina2.Form1..ctor() in C:\Users\Trufa\documents\visual studio 2010\Projects\Viernes 7\cocina2\Form1.cs:line 23
       at cocina2.Program.Main() in C:\Users\Trufa\Documents\Visual Studio 2010\Projects\Viernes 7\cocina2\Program.cs:line 18
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 

I'm not sure what is the problem since I seem to be authorized.

Trufa
  • 39,971
  • 43
  • 126
  • 190

1 Answers1

1

If you cut and paste the path into explorer, remove the extra slashes, does it open the file?

How are you running the program (in debug mode?)?

Have you tried running the program and Visual Studio as Administrator?

Does it work if you set up a new share in c:\ with Everyone permissions?

Robert Wagner
  • 17,515
  • 9
  • 56
  • 72