无法使用C#在Windows 7中以编程方式编辑FileZilla Server.xml文件?

时间:2012-05-08 10:17:04

标签: c# c#-4.0 windows-7 filezilla

我在Windows 7中使用了我的C#windows窗口应用程序的filezilla [版本0.9.39 beta]。因此,我在C:\ Program Files \ FileZilla Server \ FileZilla Server.xml文件中以编程方式添加了用户和相应的共享目录。但是,当我打开Filezilla服务器界面并在右侧框中看到用户列表时,它永远不会显示在上述文件中添加的用户列表。[见附图]

enter image description here

我还关闭了Windows 7中的UAC设置。

如何以编程方式在filezilla server.xml文件中添加用户。

请指导我解决这个问题?

谢谢&问候, P.SARAVANAN

3 个答案:

答案 0 :(得分:2)

添加用户后执行此操作:

System.Diagnostics.Process.Start("CMD.exe","/C "+fileZillaPath + "\\\"FileZilla Server.exe\" /reload-config");

答案 1 :(得分:0)

这是一个小小的修正:

string pathtofilezilla = @"C:\Program Files\FileZilla Server";
System.Diagnostics.Process.Start("CMD.exe", "/C \"" + pathtofilezilla + "\\FileZilla Server.exe\" /reload-config");

答案 2 :(得分:0)

确保输入正确的标签!我有同样的问题,问题只是"字符。我将此方法用于我的SQL数据库和FileZilla用户注册

SqlCommand command = new SqlCommand("UPDATE users SET status = 1 WHERE status=0;", kapcsolat);
        command.ExecuteNonQuery();
        //folyamat();
        string hely = @"C:\xampp\FileZillaFTP\FileZilla Server.xml";
        try
        {
            StreamWriter wr = new StreamWriter(hely, false);
            wr.WriteLine("<FileZillaServer>");
            wr.WriteLine("      <Settings>");
            wr.WriteLine("      <Item name=\"Admin port\" type=\"numeric\">14147</Item>");
            wr.WriteLine("    </Settings>");
            wr.WriteLine("  <Groups />");
            wr.WriteLine("  <Users>");
            for (int i = 0; i < dataGridView1.RowCount; i++)
            {
                DirectoryInfo di = Directory.CreateDirectory(@"C:\\FTPUsers\" + dataGridView1.Rows[i].Cells[0].Value);
                wr.WriteLine(" <User Name=\"" + dataGridView1.Rows[i].Cells[0].Value + "\">");
                wr.WriteLine("      <Option Name=\"Pass\">" + dataGridView1.Rows[i].Cells[1].Value + "</Option>");
                wr.WriteLine("      <Option Name=\"Group\"></Option>");
                wr.WriteLine("      <Option Name=\"Bypass server userlimit\">0</Option>");
                wr.WriteLine("       <Option Name=\"User Limit\">0</Option>");
                wr.WriteLine("      <Option Name=\"IP Limit\">0</Option>");
                wr.WriteLine("      <Option Name=\"Enabled\">1</Option>");
                wr.WriteLine("      <Option Name=\"Comments\"></Option>");
                wr.WriteLine("      <Option Name=\"ForceSsl\">0</Option>");
                wr.WriteLine("   <IpFilter>");
                wr.WriteLine("      <Disallowed />");
                wr.WriteLine("      <Allowed />");
                wr.WriteLine("  </IpFilter>");
                wr.WriteLine("  <Permissions>");
                wr.WriteLine("      <Permission Dir=\"C:\\FTPUsers\\" + dataGridView1.Rows[i].Cells[0].Value + "\">");
                wr.WriteLine("      <Option Name=\"FileRead\">1</Option>");
                wr.WriteLine("      <Option Name=\"FileWrite\">1</Option>");
                wr.WriteLine("      <Option Name=\"FileDelete\">1</Option>");
                wr.WriteLine("      <Option Name=\"FileAppend\">1</Option>");
                wr.WriteLine("      <Option Name=\"DirCreate\">1</Option>");
                wr.WriteLine("      <Option Name=\"DirDelete\">1</Option>");
                wr.WriteLine("      <Option Name=\"DirList\">1</Option>");
                wr.WriteLine("      <Option Name=\"DirSubdirs\">1</Option>");
                wr.WriteLine("      <Option Name=\"IsHome\">1</Option>");
                wr.WriteLine("      <Option Name=\"AutoCreate\">0</Option>");
                wr.WriteLine("    </Permission>");
                wr.WriteLine("  </Permissions>");
                wr.WriteLine("<SpeedLimits DlType=\"0\" DlLimit=\"10\" ServerDlLimitBypass=\"0\" UlType=\"0\" UlLimit=\"10\" ServerUlLimitBypass=\"0\">");
                wr.WriteLine("              <Download />");
                wr.WriteLine("          <Upload />");
                wr.WriteLine("      </SpeedLimits>");
                wr.WriteLine("</User>");
            }
            wr.WriteLine("  </Users>");
            wr.WriteLine("</FileZillaServer>");
            wr.Close();