1

我有两台没有密码的计算机连接到无线网络。

文件在计算机 A 上,程序在计算机 B 上。

从操作系统我可以毫无问题地访问和修改 B 中的 A 中的文件:

在此处输入图像描述

当我运行程序时:

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

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

它给了我以下例外:

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: 

我不确定是什么问题,因为我似乎已获得授权。

4

1 回答 1

1

如果将路径剪切并粘贴到资源管理器中,删除多余的斜杠,它会打开文件吗?

你是如何运行程序的(在调试模式下?)?

您是否尝试过以管理员身份运行程序和 Visual Studio?

如果您在 c:\ 中设置具有所有人权限的新共享,它是否有效?

于 2012-06-02T04:44:06.757 回答