Windows服务有时将少量文件保存到C盘而不是保存到C#中的特定路径 [英] Windows service saving few files to C drive at times rather than saving to specific path in C#

查看:166
本文介绍了Windows服务有时将少量文件保存到C盘而不是保存到C#中的特定路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个Windows服务应用程序,它必须将文件存储在特定位置。但有时它会将少量文件保存到C盘。为什么会出现这个问题。请帮忙。



我尝试过:



string Path = @C:\Testing\Logs;

这是要保存的路径,但它保存在C盘中。

Hi,
I have a windows service application which has to store the files in specific location. But sometimes it is saving few files to C drive. Why is this problem occurring. Please help.

What I have tried:

string Path=@"C:\Testing\Logs";
This is the path to be saved but it saves in C drive.

推荐答案

Quote:

string Path=@"C:\Testing\Logs";



这是要保存的路径,但它保存在C盘中。


This is the path to be saved but it saves in C drive.



好​​吧......它会。这就是文件路径的C:部分应该发生的事情。

如果你想将数据保存在不同的磁盘上,那么将C:改为D:或E: 或者看起来合适的东西。



但是不要这样做:永远不要硬编码文件夹 - 从配置文件或类似文件中读取它们。


Well yes...it will. That is what the "C:" part of the file path specifies should happen.
If you want data saved on a different disk, then change "C:" to "D:" or "E:" or whatever seems appropriate.

But don't do it like that: never hardcode folders - read them from a configuration file or similar.


这篇关于Windows服务有时将少量文件保存到C盘而不是保存到C#中的特定路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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