c# b/s模式下实现
1.检测网络共享文件夹是否可用
2.向该文件夹中写入文件
用什么类实现?

解决方案 »

  1.   

    注意是webform不是winform
    请不要出现"服务端"/"客户端"/"Socket"之类的
      

  2.   

    ftpwebrequest
    try catch
    httpwebrquest
    webclient
      

  3.   

    这个网络文件夹首先是共享,并且你的asp.net程序可以访问到的。
    1、如果这个网络文件夹是通过ftp方式对外开放的,你可以通过ftp操作,去访问,来判断文件夹是否存在,存在后就可以上传文件(写入)
    2、如果这个网络文件夹是通过网络共享的方式开放的,你应该就可以通过创建一个FileInfo指向它,去判断。   

  4.   

    恩,是第二种方式开放的,“可以通过创建一个FileInfo指向它” 怎么指向呢?请赐教!谢谢!
      

  5.   

    using System;
    using System.IO;class Test 
    {
        
        public static void Main() 
        {
            string path = @"c:\temp\MyTest.txt";
            FileInfo fi1 = new FileInfo(path);        if (!fi1.Exists) 
            {
                //Create a file to write to.
                using (StreamWriter sw = fi1.CreateText()) 
                {
                    sw.WriteLine("Hello");
                    sw.WriteLine("And");
                    sw.WriteLine("Welcome");
                }    
            }        //Open the file to read from.
            using (StreamReader sr = fi1.OpenText()) 
            {
                string s = "";
                while ((s = sr.ReadLine()) != null) 
                {
                    Console.WriteLine(s);
                }
            }        try 
            {
                string path2 = path + "temp";
                FileInfo fi2 = new FileInfo(path2);            //Ensure that the target does not exist.
                fi2.Delete();            //Copy the file.
                fi1.CopyTo(path2);
                Console.WriteLine("{0} was copied to {1}.", path, path2);            //Delete the newly created file.
                fi2.Delete();
                Console.WriteLine("{0} was successfully deleted.", path2);        } 
            catch (Exception e) 
            {
                Console.WriteLine("The process failed: {0}", e.ToString());
            }
        }
    }