当前位置: 首页 > wzjs >正文

免费建建网站厦门营销型网站建设公司

免费建建网站,厦门营销型网站建设公司,温州平台公司,汉滨区住房和城乡建设局网站初级代码游戏的专栏介绍与文章目录-CSDN博客 我的github:codetoys,所有代码都将会位于ctfc库中。已经放入库中我会指出在库中的位置。 这些代码大部分以Linux为目标但部分代码是纯C的,可以在任何平台上使用。 源码指引:github源…

初级代码游戏的专栏介绍与文章目录-CSDN博客

我的github:codetoys,所有代码都将会位于ctfc库中。已经放入库中我会指出在库中的位置。

这些代码大部分以Linux为目标但部分代码是纯C++的,可以在任何平台上使用。

源码指引:github源码指引_初级代码游戏的博客-CSDN博客

C#是我多年以来的业余爱好,新搞的东西能用C#的就用C#了。


        如果我们要写入文件,原有的普通目录的文件读写都是没问题的。但是默认位置是不可用的,写入文件“a.txt”会失败,因为默认位置是程序所在位置,这个位置只有系统可以修改。

        在新的应用程序管理体系下,程序自己的输出文件可以放在特殊目录LocalApplicationData或ApplicationData下。

目录

一、Windows的特殊目录

二、LocalApplicationData的实际位置

三、代码示例


一、Windows的特殊目录

        特殊目录本身并不是新鲜东西,只不过由于安装在程序组下的传统应用可以在程序所在目录下随意修改,所以一般我们并不关注特殊目录。

        特殊目录由Environment.SpecialFolder枚举定义(下面的图表来自官方文档):

NameValueDescription
Desktop0

The logical Desktop rather than the physical file system location.

Programs2

The directory that contains the user's program groups.

MyDocuments5

The My Documents folder. This member is equivalent to Personal.

Personal5

The directory that serves as a common repository for documents. This member is equivalent to MyDocuments.

Favorites6

The directory that serves as a common repository for the user's favorite items.

Startup7

The directory that corresponds to the user's Startup program group. The system starts these programs whenever a user logs on or starts Windows.

Recent8

The directory that contains the user's most recently used documents.

SendTo9

The directory that contains the Send To menu items.

StartMenu11

The directory that contains the Start menu items.

MyMusic13

The My Music folder.

MyVideos14

The file system directory that serves as a repository for videos that belong to a user.

DesktopDirectory16

The directory used to physically store file objects on the desktop. Do not confuse this directory with the desktop folder itself, which is a virtual folder.

MyComputer17

The My Computer folder. When passed to the Environment.GetFolderPath method, the MyComputer enumeration member always yields the empty string ("") because no path is defined for the My Computer folder.

NetworkShortcuts19

A file system directory that contains the link objects that may exist in the My Network Places virtual folder.

Fonts20

A virtual folder that contains fonts.

Templates21

The directory that serves as a common repository for document templates.

CommonStartMenu22

The file system directory that contains the programs and folders that appear on the Start menu for all users.

CommonPrograms23

A folder for components that are shared across applications.

CommonStartup24

The file system directory that contains the programs that appear in the Startup folder for all users.

CommonDesktopDirectory25

The file system directory that contains files and folders that appear on the desktop for all users.

ApplicationData26

The directory that serves as a common repository for application-specific data for the current roaming user. A roaming user works on more than one computer on a network. A roaming user's profile is kept on a server on the network and is loaded onto a system when the user logs on.

PrinterShortcuts27

The file system directory that contains the link objects that can exist in the Printers virtual folder.

LocalApplicationData28

The directory that serves as a common repository for application-specific data that is used by the current, non-roaming user.

InternetCache32

The directory that serves as a common repository for temporary Internet files.

Cookies33

The directory that serves as a common repository for Internet cookies.

History34

The directory that serves as a common repository for Internet history items.

CommonApplicationData35

The directory that serves as a common repository for application-specific data that is used by all users.

Windows36

The Windows directory or SYSROOT. This corresponds to the %windir% or %SYSTEMROOT% environment variables.

System37

The System directory.

ProgramFiles38

The program files directory.

In a non-x86 process, passing ProgramFiles to the GetFolderPath(Environment+SpecialFolder) method returns the path for non-x86 programs. To get the x86 program files directory in a non-x86 process, use the ProgramFilesX86 member.

MyPictures39

The My Pictures folder.

UserProfile40

The user's profile folder. Applications should not create files or folders at this level; they should put their data under the locations referred to by ApplicationData.

SystemX8641

The Windows System folder.

ProgramFilesX8642

The x86 Program Files folder.

CommonProgramFiles43

The directory for components that are shared across applications.

To get the x86 common program files directory in a non-x86 process, use the ProgramFilesX86 member.

CommonProgramFilesX8644

The Program Files folder.

CommonTemplates45

The file system directory that contains the templates that are available to all users.

CommonDocuments46

The file system directory that contains documents that are common to all users.

CommonAdminTools47

The file system directory that contains administrative tools for all users of the computer.

AdminTools48

The file system directory that is used to store administrative tools for an individual user. The Microsoft Management Console (MMC) will save customized consoles to this directory, and it will roam with the user.

CommonMusic53

The file system directory that serves as a repository for music files common to all users.

CommonPictures54

The file system directory that serves as a repository for image files common to all users.

CommonVideos55

The file system directory that serves as a repository for video files common to all users.

Resources56

The file system directory that contains resource data.

LocalizedResources57

The file system directory that contains localized resource data.

58

This value is recognized in Windows Vista for backward compatibility, but the special folder itself is no longer used.

CDBurning59

The file system directory that acts as a staging area for files waiting to be written to a CD.

        常用的几个:

  • Desktop 桌面
  • MyDocuments 文档
  • ProgramFiles 程序,注意,在x64上有两个目录,这个取64位的
  • ProgramFilesX86 程序,用于x64系统上取32位程序的目录,典型是“C:\Program Files (x86)”
  • CommonDocuments 公共文档,这个有一些妙处,如果需要多用户交互或者服务和用户交互(服务一般是独立身份,在用户登录之前就启动了),可以通过公共文档进行 (当然,只适合低强度的交互)
  • LocalApplicationData 本地程序数据
  • ApplicationData 漫游程序数据,会自动多设备同步(具体啥效果没用过)

二、LocalApplicationData的实际位置

        传统应用的LocalApplicationData位置是“用户目录\AppData\Local”,一般我们在这下面建立自己的公司目录,公司目录下面建立程序目录。

        现代应用中间包了一层,同样的调用并不会返回传统的目录,而是被系统管理的目录(在这个目录里面):

“用户目录\AppData\Local\Packages\发布者.程序名_长串后缀”

        在这个目录下有很多东西:

                在这面的“LocalCache\Local”才是LocalApplicationData的实际位置。

三、代码示例

        代码很简单,并没有什么不同:

					StreamWriter​​ sw = new StreamWriter​​(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)+"\\ctDos2Unix.log.txt", true);sw.WriteLine(logitem);sw.Close();

        此代码向文件里追加文本,如果文件不存在会创建。 

        找到位置很难,直接搜文件名就能找到输出位置。


(这里是文档结束)

http://www.dtcms.com/wzjs/799764.html

相关文章:

  • 什么是网站规划微享网络网站建设
  • 电子商务网站建设的总体设计屏蔽网站推广
  • 南通建设企业网站电影资源分享网站怎么做的
  • 成都网站建设策划在线crm客户管理系统
  • 网站推广方法有哪几种山东网络推广优化排名
  • 了解做房产广告的网站宁波网站推广方式
  • 网站开发外包合同范本wordpress 外链转内链 页面
  • 南京网站建网站建设纳千网络
  • 汕头网站快速排名优化龙岗网站制作公司
  • 资深的家居行业网站开发国内seo服务商
  • 电子商务网站建设项目的阶段杭州互助盘网站开发
  • 中国教学网站足球网站模板
  • 无锡网站建设设计公司上市公司年报查询网站
  • 建设个招聘网站成都微信网站设计
  • 网站目标十大耐玩手机单机游戏
  • 建设项目环保竣工信息公开网站wordpress 设置网站目录权限
  • 高端做网站价格科技新闻最新消息10条
  • 专注大连网站建设企业微信网站怎么建设
  • 2.0网站线上建设什么意思浙江标力建设集团网站
  • 门户网站如何运营怎么在网上做广告
  • 用国外服务器做网站做那个免费观看视频网站
  • 成都网站seo公司开网店一年的费用
  • 网站建设总做总结门业网站 源码
  • 手机网站建设 苏州广告投放渠道
  • 提供徐州网站建设做外贸网站
  • 个人怎么进行网络广告营销关键词优化包年推广
  • 网站开发者工具下载网站备案到公司名称
  • 改动网站标题标题seo是什么意思
  • 临时网站怎么做找人做网站注意事项
  • 个人门户网站备案流程怎么建设自己的论坛网站