Blazor FileSystemAccess 项目教程

Blazor FileSystemAccess 项目教程

Blazor.FileSystemAccessA Blazor wrapper for the File System Access browser API.项目地址:https://gitcode.com/gh_mirrors/bl/Blazor.FileSystemAccess

1、项目的目录结构及介绍

Blazor.FileSystemAccess/
├── docs/
│   └── 文档和示例
├── samples/
│   └── 示例代码
├── src/
│   └── KristofferStrube.Blazor.FileSystemAccess/
│       ├── Blazor.FileSystemAccess.sln
│       ├── CHANGELOG.md
│       ├── CONTRIBUTING.md
│       ├── LICENSE
│       ├── README.md
│       └── 项目源代码
├── .gitignore
├── Blazor.FileSystemAccess.sln
├── CHANGELOG.md
├── CONTRIBUTING.md
├── LICENSE
└── README.md
  • docs/: 包含项目的文档和示例。
  • samples/: 包含示例代码。
  • src/: 包含项目的主要源代码。
    • KristofferStrube.Blazor.FileSystemAccess/: 项目的主要源代码目录。
      • Blazor.FileSystemAccess.sln: 解决方案文件。
      • CHANGELOG.md: 变更日志。
      • CONTRIBUTING.md: 贡献指南。
      • LICENSE: 许可证文件。
      • README.md: 项目说明文件。
  • .gitignore: Git 忽略文件。
  • Blazor.FileSystemAccess.sln: 解决方案文件。
  • CHANGELOG.md: 变更日志。
  • CONTRIBUTING.md: 贡献指南。
  • LICENSE: 许可证文件。
  • README.md: 项目说明文件。

2、项目的启动文件介绍

项目的启动文件位于 src/KristofferStrube.Blazor.FileSystemAccess/ 目录下,主要包括以下文件:

  • Program.cs: 项目的入口文件,负责配置和启动应用程序。
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
// 其他配置代码
await builder.Build().RunAsync();

3、项目的配置文件介绍

项目的配置文件主要包括以下文件:

  • appsettings.json: 应用程序的配置文件,包含各种配置选项。
{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Warning"
    }
  },
  "AllowedHosts": "*"
}
  • Blazor.FileSystemAccess.sln: 解决方案文件,用于管理项目的各个部分。
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30114.105
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Blazor.FileSystemAccess", "src\KristofferStrube.Blazor.FileSystemAccess\Blazor.FileSystemAccess.csproj", "{项目GUID}"
EndProject
Global
  GlobalSection(SolutionConfigurationPlatforms) = preSolution
    Debug|Any CPU = Debug|Any CPU
    Release|Any CPU = Release|Any CPU
  EndGlobalSection
  GlobalSection(ProjectConfigurationPlatforms) = postSolution
    {项目GUID}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
    {项目GUID}.Debug|Any CPU.Build.0 = Debug|Any CPU
    {项目GUID}.Release|Any CPU.ActiveCfg = Release|Any CPU
    {项目GUID}.Release|Any CPU.Build.0 = Release|Any CPU
  EndGlobalSection
  GlobalSection(SolutionProperties) = preSolution
    HideSolutionNode = FALSE
  EndGlobalSection
EndGlobal

以上是 Blazor FileSystemAccess 项目的目录结构、启动文件和配置文件的介绍。希望这份文档能帮助你更好地理解和使用该项目。

Blazor.FileSystemAccessA Blazor wrapper for the File System Access browser API.项目地址:https://gitcode.com/gh_mirrors/bl/Blazor.FileSystemAccess

您可以按照以下步骤将Blazor Server项目配置为WinForms应用程序: 1. 在Visual Studio中打开Blazor Server项目。 2. 在解决方案资源管理器中,右键单击项目并选择“添加”>“新建项”。 3. 在“添加新项”对话框中,选择“WinForms应用程序”并设置名称和位置。 4. 在WinForms应用程序项目中,打开Program.cs文件并添加以下代码: ``` public static class Program { [STAThread] static void Main() { Application.SetHighDpiMode(HighDpiMode.SystemAware); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); var builder = WebAssemblyHostBuilder.CreateDefault(args); builder.RootComponents.Add<App>("app"); builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); var host = builder.Build(); Application.Run(new MainForm(host)); } } ``` 5. 创建一个新的WinForms窗体,并添加以下代码: ``` public partial class MainForm : Form { private readonly WebAssemblyHost _host; public MainForm(WebAssemblyHost host) { InitializeComponent(); _host = host; } private void MainForm_Load(object sender, EventArgs e) { _host.RunAsync(); } private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { _host.Dispose(); } } ``` 6. 在MainForm.Designer.cs文件中,将窗体的“AutoScaleMode”属性设置为“Dpi”。 7. 在Blazor Server项目中,打开Startup.cs文件并添加以下代码: ``` public void ConfigureServices(IServiceCollection services) { services.AddRazorPages(); services.AddServerSideBlazor(); } public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseStaticFiles(); app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapBlazorHub(); endpoints.MapFallbackToPage("/_Host"); }); } ``` 8. 在WinForms应用程序项目中,右键单击“引用”并选择“添加引用”。 9. 在“引用管理器”中,选择“项目”并选择Blazor Server项目。 10. 在“引用管理器”中,右键单击Blazor Server项目并选择“属性”。 11. 在“属性”窗口中,将“输出类型”设置为“类库”。 12. 在WinForms应用程序项目中,打开“应用程序配置文件”(app.config)并添加以下代码: ``` <configuration> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="Microsoft.AspNetCore.SignalR.Client.Core" publicKeyToken="adb9793829ddae60" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Net.Http.Json" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" /> </dependentAssembly> </assemblyBinding> </runtime> </configuration> ``` 13. 在WinForms应用程序项目中,右键单击“应用程序”并选择“属性”。 14. 在“应用程序”窗口中,将“启动对象”设置为“Program”。 15. 构建WinForms应用程序。 现在,您已经将Blazor Server项目配置为WinForms应用程序。运行应用程序时,将显示一个WinForms窗体,其中包含Blazor Server应用程序。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

计蕴斯Lowell

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值