编程环境:vs.net 2003
语言:c#
如何判断目录是否存在,共有三种:
1.本机的硬盘目录,如c:\test;------------已经解决
2.映射的本机硬盘目录,如c:\test影射为Z:,判断Z:是否存在;---------没有解决
3.映射的局域网内的其他电脑的硬盘目录,如名称为MyComputer的电脑,其C硬盘有c:\test,判断是否存在;---------没有解决
4.Web上的,一个硬盘空间,如知道IP:192.160.2.77,硬盘目录C硬盘有c:\test,判断是否存在;-----没有解决

解决方案 »

  1.   

    網絡上的硬盤應為192.168.2.77\\c$\\test吧。好象是這樣的。
      

  2.   

    to tjvictor(初学者) ( ) 
    你提供的方法,好象可以啊
      

  3.   

    网络通过IP+目录可以访问的,但最好还是通过Http协议访问,通过TCP/IP或Ftp无法通过防火墙的
      

  4.   

    to tjvictor(初学者) ( ) 
    你提供的方法,好象不可以啊
      

  5.   

    要想访问远程机器
    必须知道用户名密码然后连接
    而且只能访问共享目录连接可以用net use 命令
    也可以用WMI或者建立网络映射
    http://community.csdn.net/Expert/TopicView3.asp?id=5137183
      

  6.   

    问题解决,揭贴,以方便后来者,将解决方法贴出
    此处为作者写的一个类:
    using System.Collections.Specialized;
    /// <summary>
    /// get hbldocument folder, intranet
    /// </summary>
    /// 2006-11-08 Jason 
    /// <param name="remoteHost">computer ip or name</param>
    /// <param name="userName">user name</param>
    /// <param name="passWord">password</param>
    /// <returns>true:success;</returns>
    public bool ConnectNet(string remoteHost, string userName, string passWord)
    {
    bool Flag = true;
    Process myproc = new Process();
    try
    {
    myproc.StartInfo.FileName = "cmd.exe";
    myproc.StartInfo.UseShellExecute = false;
    myproc.StartInfo.RedirectStandardInput = true;
    myproc.StartInfo.RedirectStandardOutput = true;
    myproc.StartInfo.RedirectStandardError = true;
    myproc.StartInfo.CreateNoWindow = false;
    myproc.Start();
    string dosLine = @"net use " + remoteHost + " " + passWord + " " + " /user:" + userName + ">NUL";
    myproc.StandardInput.WriteLine(dosLine);
    myproc.StandardInput.WriteLine("exit");
    while (myproc.HasExited == false)
    {
    myproc.WaitForExit(1000);
    }
    string errormsg = myproc.StandardError.ReadToEnd();
    if (errormsg != "")
    {
    Flag = false;
    }
    myproc.StandardError.Close();
    }
    catch (Exception ex)
    {
    Flag = false;
    string errmsg = ex.Message;
    }
    finally
    {
    try
    {
    myproc.Close();
    myproc.Dispose();
    }
    catch(Exception ex)
    {
    Flag = false;
    string errmsg = ex.Message;
    }
    }
    return Flag;
    }
    在页面中引用如下:
    using System.IO;
    using System.Collections.Specialized;
    if(!this.ConnectNet(folder_path,ls_usrid,ls_pswd))
    {
    DirectoryInfo di = new DirectoryInfo(folder_path);
    FileInfo[] fi = di.GetFiles();
    NameValueCollection files = new NameValueCollection();
    for (int i = 0; i < fi.Length; i++)
    {
    File.Copy(folder_path + "\\" + fi[i].Name, Server.MapPath("..") + "\\" + fi[i].Name, true);
    }
    }Trakback:http://blog.csdn.net/FollowIT/archive/2006/11/09/1375494.aspx