string localpath; //映射为本地的盘符 private void MoreNas_Click(object sender, MouseButtonEventArgs e) { string remotepath; //NAS将要映射的共享文件夹 Configuration config = System.Configuration.ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); string user = config.AppSettings.Settings["nasusername"].Value; string password = config.AppSettings.Settings["naspassword"].Value; string nasconnect = config.AppSettings.Settings["naslongconnect"].Value; if (nasconnect.Equals("true")) { string path = ""; //保存选择文件夹的名称 FolderBrowserDialog dilog = new FolderBrowserDialog(); dilog.Description = "请选择文件夹"; dilog.ShowDialog(); remotepath = dilog.SelectedPath; FindDiskName(); NasFunction.Get_Share(remotepath, localpath, user, password); } else { System.Windows.Forms.MessageBox.Show("NAS长连接未打开"); } config.Save(ConfigurationSaveMode.Modified); System.Configuration.ConfigurationManager.RefreshSection("appSettings"); }
private void Login_Button_Click(object sender, RoutedEventArgs e) { string username; string password; string remotepath; //NAS将要映射的共享文件夹 string localpath; //映射为本地的盘符 //string nasname = this.NasNameTextBox.Text; username = this.UserNameTextBox.Text; password = this.PasswordTextBox.Password; //string username = "******"; //NAS的账户 //string password = "******"; //NAS的密码 //Device device = new Device(nasname, username, password); if ((username == "") || (password == "")) { System.Windows.Forms.MessageBox.Show("账号密码为空"); return; } string path = ""; //保存选择文件夹的名称 FolderBrowserDialog dilog = new FolderBrowserDialog(); dilog.Description = "请选择文件夹"; dilog.ShowDialog(); remotepath = dilog.SelectedPath; localpath = NasFunction.FindDiskName(); NasFunction.Get_Share(remotepath, localpath, username, password); if (NasCheckBox.IsChecked == true) { util.config.ConfigUtil.SetValue("nascheckbox", "true"); } else { util.config.ConfigUtil.SetValue("nascheckbox", "false"); } util.config.ConfigUtil.SetValue("nasusername", username); util.config.ConfigUtil.SetValue("naspassword", password); util.config.ConfigUtil.SetValue("naslongconnect", "true"); //config.AppSettings.Settings["nasdir"].Value = nas_dir; MainWindow.main.Status_Nas = "NAS已连接"; this.Close(); }