代码之家  ›  专栏  ›  技术社区  ›  rojoca

.NET(2.0)服务看不到网络共享

  •  1
  • rojoca  · 技术社区  · 15 年前

    我有一个C.NET服务,运行方式为 DOMAIN\username 在Windows服务器上,它需要访问网络共享 \\share\export docs$\ .

    如果我登录到机器(如 域名用户名 )我可以看到这个共享,我甚至把它映射到 X: 尝试使用它。我在app.config中设置了路径(并重新启动服务),如果在 C: 它很好用,但是如果我试着用 \\共享\导出文档$\ X:\ 它看不到我需要访问的任何文件。

    我尝试以本地用户和 域名用户名

    你知道我做错了什么吗?

    编辑:stacktrace来自日志:

    Could not find a part of the path 'X:\200909\11324709\coo.pdf'.
        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)
        at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
        at System.Net.Mail.AttachmentBase.SetContentFromFile(String fileName, String mediaType)
    

    at system.net.mail.attachment..ctor(字符串文件名)

    2 回复  |  直到 15 年前
        1
  •  1
  •   Community kfsone    7 年前

    .NET中的映射驱动器有点问题。然而,这种情况在这里出现了很多问题。最好指定UNC路径。

    这和你问的问题不完全一样,但这篇文章与你的问题有关,应该能帮助你解决问题。

    How do I access a file share programattically

        2
  •  0
  •   Scrappydog    15 年前

    以域\用户名“应该”的身份运行服务。

    您确定该帐户具有“作为服务登录”权限吗?