C#,入门教程(07)——软件项目的源文件与目录结构 - 需要 App_Code 下的主要代码支持的功能

📅 2026-12-01 👤 拼多多助力营销技巧 📂 拼多多助力2026 👁️ 594 次阅读

C#,入门教程(06)——解决方案资源管理器,代码文件与文件夹的管理工具https://blog.csdn.net/beijinghorn/article/details/124895033

创建新的 C# 项目后, Visual Studio 会自动创建一系列的目录与文件。 程序员后面的工作就是在这个目录及这些文件的基础上进行的。 本文对这些目录与文件做一个概要性的解释。

一、目录

1、默认的目录

Visual Studio 默认创建 3 个子目录及下层的目录。

\bin

\---Debug

\---Release

\obj

\---Debug

\---Release

\Properties

\bin 目录保存项目生成的程序集(.exe 或 .dll) \bin\Debug 保存“调式版本Debug”模式的文件,一般都是在这个目录下能找到可执行文件 .exe \bin\Release 保存“正式发布版本Release”模式的文件

\obj 目录保存项目的编译临时文件(一般无需操心) \obj\Debug 保存“调式版本Debug”模式的文件 \obj\Release 保存“正式发布版本Release”模式的文件

\Properties 目录保存项目相关的一些设置信息,一般无需阅读与修改。

2、改良与更好的目录结构

建议在工程目录下创建 App_Code 子目录,用以保存工程相关的所有 namespace 的 class 文件。 并且按类别予以区分。比如,幸运之门50018.COM的目录结构:

\App_Code

\App_Code\Basic 存储常用的 Helper 类的基础静态类

\App_Code\K50018 存储核心数据分类代码

\App_Code\K50018\Basic 数据分析的基础代码

\App_Code\K50018\Entity 数据体(从数据库、文件获得)的相关代码

\App_Code\K50018\Algorithm 数据分析的算法代码

\App_Code\K50018\Graph 生成走势图表等分析结果的代码

。。。

请,举一反三!

二、文件

工程相关的文件分类两类:(1)*.cs 是C#源代码类;(2)*.else 其他类;

1、.sln 解决方案(solution)文件

.sln 是解决方案的配置文件,保存着项目project和解决方案的关系。 这个文件也是双击打开 Visual Studio 的默认文档。

Microsoft Visual Studio Solution File, Format Version 12.00

# Visual Studio Version 17

VisualStudioVersion = 17.1.32228.430

MinimumVisualStudioVersion = 10.0.40219.1

Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Desktop", "Desktop.csproj", "{D87DE9F7-951F-4392-A24B-64DF168191CA}"

EndProject

。。。

2、.csproj 工程项目(C sharp project)文件

.csproj 为c sharp project的缩写。 .csproj 项目文件,保存着源代码、其他文档、资源和本项目的归属关系。 用编辑器(推荐韩国人写的Editplus!)打开 Desktop.csproj 文件,可以看到类似这样的(XML)内容:

。。。

。。。

Form

Form1.cs

。。。

3、App.config 项目配置文件

App.config 一般是这样的XML内容。

4、Form 相关文件

(1)Form 相关

Form 是指软件的窗口。Form 相关文件是3个一组。

Form1.cs (窗口事件处理的)源代码 Form1.Designer.cs 窗口设计的源代码(初学者略过) Form1.resx 窗口设计的资源信息(初学者掠过)

Form1.cs 一般是这样的内容:

// 引用系统的命名空间

using System;

using System.IO;

using System.Text;

using System.Data;

using System.Linq;

using System.Drawing;

using System.Threading;

using System.Collections;

using System.Collections.Generic;

using System.ComponentModel;

using System.Threading.Tasks;

using System.Diagnostics;

using System.Windows.Forms;

// 引用自己开发的命名空间

using Legalsoft.K50018;

namespace Desktop_Application

{

public partial class Form1 : Form

{

// 默认构造函数

public Form1()

{

InitializeComponent();

}

// 窗口加载时候的处理

private void Form1_Load(object sender, EventArgs e)

{

}

// button1 点击事件的处理

private void button1_Click(object sender, EventArgs e)

{

//一般的代码都从这里起飞!

}

}

}

Form1.Designer.cs的内容一般这样:

namespace Desktop_Application

{

partial class Form1

{

///

/// 必需的设计器变量。

///

private System.ComponentModel.IContainer components = null;

///

/// 清理所有正在使用的资源。

///

///如果应释放托管资源,为 true;否则为 false。

protected override void Dispose(bool disposing)

{

if (disposing && (components != null))

{

components.Dispose();

}

base.Dispose(disposing);

}

#region Windows 窗体设计器生成的代码

///

/// 设计器支持所需的方法 - 不要修改

/// 使用代码编辑器修改此方法的内容。

///

private void InitializeComponent()

{

this.panel1 = new System.Windows.Forms.Panel();

this.button1 = new System.Windows.Forms.Button();

this.panel2 = new System.Windows.Forms.Panel();

this.webBrowser1 = new System.Windows.Forms.WebBrowser();

this.panel1.SuspendLayout();

this.panel2.SuspendLayout();

this.SuspendLayout();

。。。

}

}

}

Form1.resx 窗口设计的资源信息(初学者掠过)

(2)更多的窗口

如果软件设计有多个窗口,则就具有多个配套的文件。常见的有:

欢迎窗口 Welcome.cs (窗口事件处理的)源代码 Welcome.Designer.cs 窗口设计的源代码(初学者略过) Welcome.resx 窗口设计的资源信息(初学者掠过)

软件配置窗口 Setting.cs (窗口事件处理的)源代码 Setting.Designer.cs 窗口设计的源代码(初学者略过) Setting.resx 窗口设计的资源信息(初学者掠过)

软件帮助窗口 Help.cs (窗口事件处理的)源代码 Help.Designer.cs 窗口设计的源代码(初学者略过) Help.resx 窗口设计的资源信息(初学者掠过)

再见! Bye.cs (窗口事件处理的)源代码 Bye.Designer.cs 窗口设计的源代码(初学者略过) Bye.resx 窗口设计的资源信息(初学者掠过)

三、更多的项目!!!

压轴的,都是精彩的!

《幸运之门彩票网50018.COM》 有这样一系列的实际需求: (1)网站:运行于 Windows Server 2008 之 IIS 的 Web 服务; 需要 App_Code 下的所有代码支持的功能; (2)合作:运行于合作伙伴 Linux 之 Web 服务; 需要 App_Code 下的所有代码支持的功能; (3)桌面PC:《蓝彩和app》; 需要 App_Code 下的所有代码支持的功能; (4)安卓(Andriod)App:《蓝彩和app》; 需要 App_Code 下的所有代码支持的功能; (5)苹果(iOS)App:《蓝彩和app》; 需要 App_Code 下的所有代码支持的功能; (6)合作伙伴Unity游戏软件内的《CaiPiao分析》; 需要 App_Code 下的主要代码支持的功能;

于是,在我的工程目录下就有了这样一些文件:

App.config

Desktop.csproj 桌面PC软件

Desktop.sln

Web.csproj IIS网站,WEB服务

Web.sln

Linux.csproj LINUX,WEB服务

Linux.sln

MAPP-Andriod.csproj 安卓app

MAPP-Andriod.sln

MAPP-iOS.csproj 苹果app

MAPP-iOS.sln

Unity.csproj 游戏Unity app

Unity.sln

Form1.cs

Form1.Designer.cs

Form1.resx

Welcome.cs

Welcome.Designer.cs

Welcome.resx

Setting.cs

Setting.Designer.cs

Setting.resx

Help.cs

Help.Designer.cs

Help.resx

Bye.cs

Bye.Designer.cs

Bye.resx 拼多多帮助力入口

重要的是!仅仅只需要维护一个 App_Code !!!

C# 是无与伦比的!

C#,入门教程(08)——基本数据类型及使用的基础知识https://blog.csdn.net/beijinghorn/article/details/123906998

精彩内容

标签: 拼多多助力网站平台 赚钱项目 拼多多助力网 首码项目 手赚APP
拼多多助力营销技巧