在C#中部署的应用程序中需要有关错误的帮助 [英] Need help with error in my deployed application in C#

查看:79
本文介绍了在C#中部署的应用程序中需要有关错误的帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已部署了一个应用程序,该应用程序的文本文件在管理员更改时会更新为某个值。例如,应检查的当前密码是!!密码!!。假设管理员想要将其更改为@ !!密码!!,文本文件已更新,新文本将是新密码。



程序运行正常在调试时..保存密码,甚至在需要检查时进行检索。



但是,我刚刚部署了应用程序,现在出现了与该文本文件有关的所有内容的错误。关于路径的事情?但文本文件在我的项目中,并指定了所有路径。就像我说的那样在调试模式下绝对没有问题。部署应用程序后为什么不能正常工作?



这是我的错误:



找不到路径的一部分''C:\Users\Chris \ AppData \ Local \ Apps\2.0 \ YCOZGQO3.6RP \Admin \ AdminPass.txt''。



在此先感谢,

Chris

I have deployed an application that has a text file that is updated with a certain value when the administrator changes something. For example, the current password that should be checked is !!Password!!. Say the admin wants to change that to @!!Password!!, the text file is updated and the new text would be the new password.

The program runs fine while debugging.. saving the password and even retreiving it when needing to check.

However, I have just deployed the application and now there is an error with everything that has something to do with that text file. Something about a path? but the text file is in my project and all paths are specified. Like i said there is absolutely NO PROBLEM in debug mode. Why wont it work once I deployed the application?

This is my error:

Could not find a part of the path ''C:\Users\Chris\AppData\Local\Apps\2.0\YCOZGQO3.6RP\Admin\AdminPass.txt''.

Thanks in advance,
Chris

推荐答案

根据MSDN [ ^ ],可以使用以下代码序列确定执行的组合路径:

According to MSDN[^], the executing assambly path can be determined using following code sequence:
string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase );



现在使用这个和 System.IO.Path类 [ ^ ]成员构建文件的路径。


Now use this and the System.IO.Path class[^] members to construct the path to your file.


这篇关于在C#中部署的应用程序中需要有关错误的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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