-9
                 case "PWD":
                        //    Form1.ClientConnect(ClientID, clientMsg);
                            SendUpdate(ClientID + " : " + clientMsg);
                            SendMsg("257 " + "\"" + PresentDirOnFTP + "\"" + " is current directory \r\n", ref outBuffer);
                            break;
                 case "DELE":
                            //Delete the file from the Server and reply back.
                            Form1.ClientConnect(ClientID, clientMsg);
                            SendUpdate(ClientID + " : " + clientMsg);
                            clientMsg = clientMsg.Substring(4).Trim();

                            SendMsg(DeleteFileForServer(rootDirOnSystem, PresentDirOnFTP, clientMsg), ref outBuffer);
                            break;
         private string DeleteFileForServer(string rootDirOnServer, string PresentDirOfFTP, string fileName)
    {
        //check for seperator
        Thread oThread = Thread.CurrentThread;
        lock (oThread)
        {
            string root = FilePath(rootDirOnServer, PresentDirOfFTP, fileName);
            try
            {
                FileInfo oFile = new FileInfo(root);
                if (oFile.FullName != "")
                {
                    oFile.Delete();
                    return "250 delete command successful\r\n";
                }
            }
            catch (FileNotFoundException e)
            {
                //Form1.ClientConnect(ClientID, e.ToString());
                SendUpdate(ClientID + " : " + e.ToString());
                return "550 file not found, or no access.\r\n";
            }
            catch (IOException e)
            {
               // Form1.ClientConnect(ClientID, e.ToString());
                SendUpdate(ClientID + " : " + e.ToString());
                return "550 file not found, or no access.\r\n";
            }
           // Form1.ClientConnect(ClientID, "Error in Deleteing file " + fileName);
            SendUpdate(ClientID + " : " + "Error in Deleteing file " + fileName);
            return "550 file not found, or no access.\r\n";
        }
    }

コマンド DELE を使用してサーバーからフォルダーを再帰的に削除する方法は? Thx とても... dfsdfds f dsfsdfsdfsd fsdfds

4

1 に答える 1

6

これを試して

Directory.Delete(topPath, true);

2 番目のパラメーターは、削除が再帰的に行われることを示しています。

于 2013-05-21T15:21:15.120 に答える