.NET项目中的空文件夹 [英] empty folder in .NET project

查看:73
本文介绍了.NET项目中的空文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





作为.NET安装项目的一部分,我需要创建一个空目录C:\ test\log。

这个目录将被其他一些进程用来创建日志。



无论安装文件夹作为程序文件中的安装,都必须创建此文件夹。



如何在指定位置的.NET安装项目中创建一个空文件夹?



提前感谢。



谢谢,

Shreyas



As part of .NET setup project i need to create a empty directory C:\test\log .
This directory will be used by some other process to create logs.

This folder has to be created irrespective of installtion folder as installtion in program files.

How can a create an empty folder in .NET setup project at a specified location ?

Thanks in advance.

Thanks,
Shreyas

推荐答案

我依赖于设置框架您正在使用。答案会有很大不同。



我不建议你这样做。首先,您可以在标准位置编写应用程序生成的数据。请参阅我过去的回答:

如何找到我的程序目录 [ ^ ]。



此外,还有一种标准的日志记录方法: http://msdn.microsoft.com/en-us/library/system.diagnostics.eventlog.aspx [ ^ ]。



基本上,问题在于:您要创建和使用的目录对于较新的Windows版本,Windows 7及更高版本是非法的(我不想提及Vista,认为它失败了) 。因此,您需要通过修改安装程序中的权限来注意使其可写。如果您使用Windows中标准化的方法,则不需要它,因此目录的创建将放在应用程序本身的代码中,它真正属于它。在编写第一个日志时,您将创建此目录。就这么简单。



-SA
I depends on the setup framework you are using. The answers would be very different.

I don't advise you to do so. First, there are standard places where you can write data generated by your application. Please see my past answer:
How to find my programs directory[^].

Also, there is a standard method of logging: http://msdn.microsoft.com/en-us/library/system.diagnostics.eventlog.aspx[^].

Essentially, the problem is this: the directory you are going to create and use is illegal for newer Windows versions, Windows 7 and later (I don't want to mention Vista, consider it failed). Therefore, you would need to take care about making it writable, by modification of its permission in the installer. If you use the approaches standardized in Windows, you won't need it and hence the creation of the directory would be put in the code of application itself, where it truly belongs. You would create this directory when you are writing the very first log. As simple as that.

—SA


这篇关于.NET项目中的空文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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