You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何检测GTA圣安地列斯游戏文件夹中的未授权文件夹?

检测GTA圣安地列斯未授权文件夹的C#实现

原代码仅验证授权文件夹的存在性,要实现检测未授权文件夹的需求,需要反向遍历游戏目录下的所有子文件夹,对比授权列表筛选出违规项,具体实现如下:

using System.IO;
using System.Linq;
using System.Windows.Forms;

// 授权文件夹列表
string[] folderNames = new[]
{
    "anim",
    "audio",
    "cleo",
    "custom_models",
    "data",
    "libraries",
    "models",
    "modloader",
    "movies",
    "SAMP",
    "text"
};

string gameFolder = oyunDizin;

// 获取游戏目录下所有一级子文件夹的名称
var allSubFolders = Directory.GetDirectories(gameFolder)
                            .Select(dir => Path.GetFileName(dir));

// 筛选出不在授权列表中的文件夹
var unauthorizedFolders = allSubFolders.Where(folder => !folderNames.Contains(folder)).ToList();

// 检查并提示未授权文件夹
if (unauthorizedFolders.Any())
{
    string errorMsg = "发现未授权文件夹:\n" + string.Join("\n", unauthorizedFolders);
    MessageBox.Show(errorMsg, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
    MessageBox.Show("所有文件夹均为授权项", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}

关键优化说明

  • 用Path.GetFileName()处理路径,避免因系统路径分隔符差异导致的错误
  • 通过LINQ简化筛选逻辑,代码更简洁易读
  • 一次性列出所有未授权文件夹,提升用户排查效率

内容的提问来源于stack exchange,提问作者Emircan Horuz

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.23 04:36:17