OSEnviron/MainForm.cs

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace OSEnviron
{
    /// <summary>
    /// 将OpenSEES添加到环境变量
    /// </summary>
    public partial class MainForm : Form
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        public MainForm()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 添加环境变量
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SelectButton_Click(object sender, EventArgs e)
        {
            //获得所有环境变量
            string path = Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.Machine);
            //判断环境变量是否存在
            if(path.Contains("OpenSees"))
            {
                //提示
                MessageBox.Show("OpenSEES Environment Variable Has Existed!", "", 
                    MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return;
            }
            //选择OpenSEES
            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.Filter = "exe(*.exe)|*.exe";
            //选择文件
            if (openFileDialog.ShowDialog() != DialogResult.OK) return;
            //获得文件路径
            var filePath = openFileDialog.FileName;
            //判断是否选择了正确的文件
            if (!filePath.Contains("OpenSees.exe"))
            {
                //提示
                MessageBox.Show("File is not CORRECT!", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            //在C盘创建文件夹
            string directoryPath = "C:\\OpenSees";
            //文件不存在时创建文件夹
后面还有 14 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。