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.