如何使用exe文件在系统上创建txtfile [英] how to create a txtfile on a system using exe file

查看:103
本文介绍了如何使用exe文件在系统上创建txtfile的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



当我尝试存储和检索txt文件时,我使用c#



在wpf windows上创建了一个项目系统工作正常,我通过innosetup安装了一个安装程序。我无法通过exe文件存储和检索系统上的数据,但它在visual studio环境下运行正常,任何机构都可以告诉我应该如何通过exe文件在系统上创建txtfile。



提前感谢你

uday

hi
I created a project on wpf windows using c#

when i am trying to store and retrieve the txt files on the system it is working fine , i made a installer through innosetup. i cant able to store and retrieve the data on the system through exe file but it is working fine on visual studio environment can any body tell me how should we create txtfile on the system through exe file .

thanking you in advance
uday

推荐答案

当你在开发中工作时,你的代码很可能看起来像:

The chances are that when you were working in development, your code looked something like:
File.WriteAllText("MyTextFile.txt", "This is a line of text");
...
string data = File.ReadAllText("MyTextFile.txt");

工作正常 - 但它将文件存储在开发机器上可读写的应用程序文件夹中,但是当你尝试在生产中执行它时,应用程序存储在Program Files文件夹,通常无法访问以防止病毒和蠕虫被篡改。



相反,请看一下:我应该在哪里存储我的数据? [ ^ ],它解释了您可以存储数据的安全地点。

which works fine - but it stores the file in the application folder which is readable and writable on your development machine, but when you try to do it in production, the application is stored under the "Program Files" folder which is not normally accessible to prevent viruses and worms fro tampering.

Instead, have a look here: Where should I store my data?[^] which explains safe places you can store data.

这篇关于如何使用exe文件在系统上创建txtfile的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆