什么也不说了,看以下实例。       

   /// <summary>
        /// 获取到的京东系统级参数保存到文件里
        /// </summary>
        /// <param name="authForm"> 窗口类</param>
        void SetInFile(AuthForm authForm)
        {
            //应用程序的可执行文件的路径
            string DirectoryPath = Application.StartupPath + "\\INI";

            //创建目录
            if (!Directory.Exists(DirectoryPath))
            {
                Directory.CreateDirectory(DirectoryPath);//目录操作
            }

            //创建文件
            string filepath = DirectoryPath + "\\JOS配置信息.ini";//文件操作
            if (File.Exists(filepath))
            {
                File.Delete(filepath);
            }

            //AppendAllText()有创建文件和写入内容的功能
            File.AppendAllText(filepath, "AppKey:" + authForm.AppKey + "\r\nAppSecret:" + authForm.AppSecret + "\r\nAccessToken:" + authForm.AccessToken.Token + "\r\nDate:" + DateTime.Now.ToString().Trim());

            Console.WriteLine("保存");
        }

相关文章:

  • 2022-12-23
  • 2021-09-09
  • 2022-12-23
  • 2021-07-07
  • 2022-12-23
  • 2021-08-27
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-22
相关资源
相似解决方案