如题,如果知道登陆名及密码,且有相应的权限,怎么通过程序往文件夹中写文件?最好能提供相关的代码。
第一次提问,不知说清没有,谢谢!

解决方案 »

  1.   

    参看
    http://blog.csdn.net/knight94/archive/2006/03/21/631309.aspx
    http://blog.csdn.net/knight94/archive/2006/03/31/645367.aspx
      

  2.   

    可以开一个进程,执行一下net use命令就行了。
    net use * \\dell1500-1\C$ password /user:cmic
      

  3.   

    用命令
    net use f: \\IP地址\d$ "密码" /user:用户名
    这样,那台电脑的D盘就映射为你的f盘了,就像本机的盘一样用了,
    再用
    at \\127.0.0.1 21:00 "notepad.exe"
    但这个at命令,操作选程要注意用户名和密码的输入
      

  4.   

    或者是象Knight94(愚翁)文章里提到的,每用一次后再删除? 这样好象也不可行吧?
      

  5.   

    http://www.codeproject.com/csharp/mapnetdrive.asp
    映射到本地机器磁盘后,只要你不删除,一直在的...
      

  6.   

    Knight94(愚翁):
    请问,函数WNetAddConnection2的返回值的错误列表是什么?到哪能查到?
    怎么我调用之后返回的是67?代表什么意思?
      

  7.   

    to 怎么我调用之后返回的是67?代表什么意思?public const int ERROR_BAD_NET_NAME = 67;
      

  8.   

    you can get other error messages in "www.pinvoke.net"
      

  9.   

    下面是sdk中的例子。
    先使用Wmi开通连接,再Copy文件
    using System;
    using System.Management;// This example demonstrates how to connect to remote machine
    // using supplied credentials.
    class Sample_ConnectionOptions
    {
        public static int Main(string[] args) {
            ConnectionOptions options = new ConnectionOptions();
            options.Username = UserName; //could be in domain\user format
            options.Password = SecurelyStoredPassword;
            ManagementScope scope = new ManagementScope(
                "\\\\servername\\root\\cimv2",
                options);
            try {
                scope.Connect();
                ManagementObject disk = new ManagementObject(
                    scope,
                    new ManagementPath("Win32_logicaldisk='c:'"),
                    null);
                disk.Get();
            }
            catch (Exception e) {
                Console.WriteLine("Failed to connect: " + e.Message);
            }
            return 0;
        }
    }