c#创建目录:

// 获取程序的基目录。
System.AppDomain.CurrentDomain.BaseDirectory

// 获取模块的完整路径。
System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName

// 获取和设置当前目录(该进程从中启动的目录)的完全限定目录。
System.Environment.CurrentDirectory

// 获取应用程序的当前工作目录。
System.IO.Directory.GetCurrentDirectory()

// 获取和设置包括该应用程序的目录的名称。
System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase

// 获取启动了应用程序的可执行文件的路径。
System.Windows.Forms.Application.StartupPath

// 获取启动了应用程序的可执行文件的路径及文件名
System.Windows.Forms.Application.ExecutablePath

//组成新的路径

string path=System.Windows.Forms.Application.StartupPath+"\\DownFile\\";

//判断该路径下文件夹是否存在,不存在的情况下新建文件夹

if(!Directory.Exists(path))

{

Directory.CreateDirectory(path);

}

//生成txt文件,将json字符串数据保存到txt文件

string postPath=path+DateTime.Now.ToString("yyyyMMddHHmmss")+".txt";//路径+文件名

byte[] bytes=null;

bytes=Encoding.UTF8.GetBytes(Obj.ToString())//Obj为json数据

FileStream fs=new FileStream(postPath,FileMode.Create);

fs.Write(bytes,0,bytes.Length);

fs.Close();

最新文章

  1. 几种常见语言的命名空间(Namespace)特性
  2. 局域网IP段
  3. express随记01
  4. Linux:实现Hadoop集群Master无密码登录(SSH)各个子节点
  5. VMware安装CentOS后网络设置
  6. js 选择器
  7. 移动端touch事件获取clientX, clientY
  8. hdu4578 线段树 三次方,二次方,一次方的值
  9. checkbox/input文本框与文字对齐
  10. PHP 文件
  11. OpenGL ES中MRT应用
  12. java方法重载和重写
  13. java连接数据库以及连接参数格式
  14. C++ 第十课:标准c时间与日期函数
  15. angular学习笔记(三十)-指令(8)-scope
  16. lower类的accessCode解读
  17. UOJ#34. 多项式乘法(NTT)
  18. C 共享内存封装
  19. 深入解析QML引擎, 第1部分:QML文件加载
  20. signal基础

热门文章

  1. 简介Python中用于处理字符串的center()方法
  2. 为何有DAO与Service层?为何先搞Dao接口在搞DaoImpl实现?直接用不行吗?
  3. CSS3 @font-face详细用法
  4. 【Leetcode_easy】657. Robot Return to Origin
  5. leetcode1140 Stone Game II
  6. Springboot 参数中传List
  7. 打印网页js
  8. Django简介 --Python Web
  9. Oracle 数据库 alert日志及trace日志的清理
  10. Appium 基于控件左滑操作