XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFEExtension

【DLL】XFE各类拓展是一个C#的DLL库,旨在优化C#代码中常用语句的使用,并提供更简洁的访问方式,同时提供Xunit测试框架,快速搭建服务器/客户端,免费ChatGPTAPI接口,免费通讯服务器,XFE下载器,新增格式等

公开
关注 0 Fork 0 Star 0
返回提交历史

XFEstudio/XFEExtension

添加删除配置文件的方法

2525150
XFE工作室室长 <mail@xfegzs.com>
提交于

代码差异

1 个文件 +49 -0
Modified XFEExtension.NetCore/ProfileExtension/XFEProfile.cs +49 -0
@@ -146,6 +146,55 @@ public abstract class XFEProfile
146 146 await SaveProfileAsync(profile);
147 147 }
148 148
149 /// <summary>
150 /// 删除指定的配置文件
151 /// </summary>
152 /// <param name="profileInfo">指定的配置文件</param>
153 public static void DeleteProfile(ProfileInfo profileInfo)
154 {
155 var waitSaveProfile = Profiles.Find(x => x.Profile == profileInfo.Profile);
156 if (waitSaveProfile is null)
157 return;
158 if (File.Exists(waitSaveProfile.Path))
159 File.Delete(waitSaveProfile.Path);
160 }
161
162 /// <summary>
163 /// 删除指定的配置文件
164 /// </summary>
165 /// <param name="profileInfo">指定的配置文件</param>
166 /// <returns></returns>
167 public static async Task DeleteProfileAsync(ProfileInfo profileInfo)
168 {
169 await Task.Run(() =>
170 {
171 var waitSaveProfile = Profiles.Find(x => x.Profile == profileInfo.Profile);
172 if (waitSaveProfile is null)
173 return;
174 if (File.Exists(waitSaveProfile.Path))
175 File.Delete(waitSaveProfile.Path);
176 });
177 }
178
179 /// <summary>
180 /// 删除所有配置文件
181 /// </summary>
182 public static void DeleteProfiles()
183 {
184 foreach (var profile in Profiles)
185 DeleteProfile(profile);
186 }
187
188 /// <summary>
189 /// 删除所有配置文件
190 /// </summary>
191 /// <returns></returns>
192 public static async Task DeleteProfilesAsync()
193 {
194 foreach (var profile in Profiles)
195 await DeleteProfileAsync(profile);
196 }
197
149 198 /// <summary>
150 199 /// 设置储存配置文件的方法
151 200 /// </summary>